Core Java - Interview Questions and Answers

491. Which of the following are Java keywords?
(multiple)
1) goto
2) malloc
3) extends
4) FALSE

Answer : 3

492. What will be the result of compiling the following code:

public class Test {
public static void main (String args []) {
int age;
age = age + 1;
System.out.println("The age is " + age);
}
}
1) Compiles and runs with no output
2) Compiles and runs printing out The age is 1
3) Compiles but generates a runtime error
4) Does not compile
5) Compiles but generates a compile time error

Answer : 4

493. Which of these is the correct format to use to create the literal char value a?
(multiple)
1) 'a'
2) "a"
3) new Character(a)
4) \000a

Answer : 1

494. What is the legal range of a byte integral type?
1) 0 - 65, 535
2) (-128) - 127
3) (-32,768) - 32,767
4) (-256) - 255

Answer : 2

495. Which of the following is illegal:
1) int i = 32;
2) float f = 45.0;
3) double d = 45.0;

Answer 2

496. What will be the result of compiling the following code:

public class Test {
static int age;
public static void main (String args []) {
age = age + 1;
System.out.println("The age is " + age);
}
}
1) Compiles and runs with no output
2) Compiles and runs printing out The age is 1
3) Compiles but generates a runtime error
4) Does not compile
5) Compiles but generates a compile time error

Answer : 2

497. Which of the following are correct?
(multiple)
1) 128 >> 1 gives 64
2) 128 >>> 1 gives 64
3) 128 >> 1 gives -64
4) 128 >>> 1 gives -64

Answer : 1

498. Which of the following return true?
(multiple)
1) "john" == new String("john")
2) "john".equals("john")
3) "john" = "john"
4) "john".equals(new Button("john"))

Answer : 2

499. Which of the following do not lead to a runtime error?
(multiple)
1) "john" + " was " + " here"
2) "john" + 3
3) 3 + 5
4) 5 + 5.5

Answer 1,2,3,4

500. Which of the following are acceptable?
(multiple)
1) Object o = new Button("A");
2) Boolean flag = true;
3) Panel p = new Frame();
4) Frame f = new Panel();
5) Panel p = new Applet();

Answer : 1,5


Coming soon ...

Post a Comment

Mới hơn Cũ hơn