Java Basic


  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 of these methods will be invoked if a character is entered?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    keyTyped()



  1. Which of the following is good coding practice to determine oddity?
    i)
    public boolean Calc(int n)
    {
    return (n & 1)!= 0;
    }

    ii)
    public boolen Calc(int n)
    {
    return n % 2 == 1;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Arithmetic and logical operations are much faster than division and multiplication.