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 gets printed on the standard output when the class below is compiled and executed. Select the one correct answer.
public class ShortCkt { public static void main(String args[]) { int i = 0; boolean t = true; boolean f = false, b; b = (t || ((i++) == 0)); b = (f || ((i+=2) > 0)); System.out.println(i); } }
0
1
2
3
public class ShortCkt { public static void main(String args[]) { int i = 0; boolean t = true; boolean f = false, b; b = (t & ((i++) == 0)); b = (f & ((i+=2) > 0)); System.out.println(i); } }
public class ShortCkt { public static void main(String args[]) { int i = 0; boolean t = true; boolean f = false, b; b = (t && ((i++) == 0)); b = (f && ((i+=2) > 0)); System.out.println(i); } }
In the second assignment to variable b, the expression (i+=2) does not get evaluated.
What gets printed when the following program is compiled and run. Select the one correct answer.
class test { public static void main(String args[]) { int i,j,k,l=0; k = l++; j = ++k; i = j++; System.out.println(i); } }
In the following class definition, which is the first line (if any) that causes a compilation error. Select the one correct answer.
public class test { public static void main(String args[]) { char c; int i; c = 'A'; // 1 i = c; //2 c = i + 1; //3 c++; //4 } }
The line labelled 1
The line labelled 2
The line labelled 3
The line labelled 4
It is not possible to assign an integer to a character in this case without a cast.
The signed right shift operator in Java is --. Select the one correct answer.
<<
>>>
>>
None of these
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
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