Java Basic


  1. Which is better in terms of performance for iterating an array?











  1. 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.


  1. Which of the below is false about java coding?











  1. 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.



  1. Which of the below is true about java class structure?











  1. 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.


  1. Which of the following is a best practice to measure time taken by a process for execution?











  1. 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.



  1. Which one of the following causes memory leak?











  1. 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.