Java Basic
- Which is better in terms of performance for iterating an array?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
reverse traversal of array take half number cycles as compared to forward traversal. The other for loops will go in infinite loop.
- Which of the below is false about java coding?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
variable names like i, a, abc, etc should be avoided. They should be real world names which avoid ambiguity. Test case name should explain its significance.
- Which of the below is true about java class structure?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Class name should always start with upper case and contain those attribute and functionality which it should (Single Responsibility Principle); hence keeping it short. The attributes should be usually private with get and set methods.
- Which of the following is a best practice to measure time taken by a process for execution?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
System.nanoTime takes around 1/100000 th of a second whereas System.currentTimeMillis takes around 1/1000th of a second.
- Which one of the following causes memory leak?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Finally block is called in successful as well exception scenarios. Hence, all the connections are closed properly which avoids memory leak.