Java Basic
- 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 of these methods will be invoked if a character is entered?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
keyTyped()
- 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;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Arithmetic and logical operations are much faster than division and multiplication.