Java Programming Questions and Answers
What is the result of compiling and running the following class. Select the one correct answer.
class Test {
public void methodA(int i) {
System.out.println(i);
}
public int methodA(int i) {
System.out.println(i+1);
return i+1;
}
public static void main(String args[]) {
Test X = new Test();
X.methodA(5);
}
}
Which of the following are valid constructors within a class Test
Which of the following are legal declaration and definition of a method.
What will the result of compiling and executing the following program. Select the one correct answer.
class Test { public static void main(String args[]) { int arr[] = new int[2]; System.out.println(arr[0]); } }
Which of these array declarations and initializations are legal?
Which of these statements is illegal.
Given a one dimensional array arr, what is the correct way of getting the number of elements in arr. Select the one correct answer
Which of the following is syntactically wrong ?
Identifier can begin with a letter, a currency character ($) or underscore (_).
Which of the following is syntactically correct ?