AmbitionBox
Discover Best Places to work in India
Discover best places to work
Compare & find best workplace
Bring your workplace to life
Highlight your company's perks
Read reviews for 6L+ companies
Rate your former or current company
Discover salaries for 8L+ companies
Calculate your take home salary
Check your market value
Help other jobseekers
Read interviews for 90K+ companies
Interviews questions for 1K+ colleges
Contribute your interview questions
Java Programming
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); } }
The program compiles and runs printing 5
The program compiles and runs printing 6
The program gives runtime exception because it does not find the method Test.methodA(int)
The program give compilation error because methodA is defined twice in class Test
Which of the following are valid constructors within a class Test
test() { }
Test() { }
Test(void) { }
void Test() { }
Which of the following are legal declaration and definition of a method.
void method() {}
void method(void) {}
method(void) {}
void 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]); } }
The program does not compile because arr[0] is being read before being initialized
The program generates a runtime exception because arr[0] is being read before being initialized
The program compiles and prints 0 when executed
The program compiles and prints 1 when executed
Which of these array declarations and initializations are legal?
int arr[4] = new int[4];
int[4] arr = new int[4];
int arr[] = new int[4][4];
int[] arr = new int[4];
Which of these statements is illegal.
int arr[][] = new int[5][5];
int []arr[] = new int[5][5];
int[][] arr = new int[5][5];
int[] arr = new int[5][];
Given a one dimensional array arr, what is the correct way of getting the number of elements in arr. Select the one correct answer
arr.length
arr.size
arr.length()
arr.length() - 1
Which of the following is syntactically wrong ?
A. int a;
B. int 1b;
C. int _a;
D. None of the above
Identifier can begin with a letter, a currency character ($) or underscore (_).
Which of the following is syntactically correct ?
A. int d2;
B. int emp;
C. int $student;
D. All of the above
Join India’s largest community to research company culture
Are you a student or working professional?
Student/Never worked
I am a student/I have never worked
Working Professional
I am working/I have worked before
What are your preferred job locations?
Popular Cities
Other Cities
Follow your preferred designations/job profiles
Suggestions based on your job profile
vs
Similar Companies