JAVA SE 8 - Fundamentals Quiz Questions and Answers

Which of these constructors is used to create an empty String object?

Answer :
  • String()

What is the output? class A { int i; } class B extends A { int j; void display() { super.i = j + 1; System.out.println(j + " " + i); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } }

Answer :
  • 2 3

Which of the following option leads to the portability and security of Java?

Answer :
  • Bytecode is executed by JVM

Which of these is an incorrect array declaration?

Answer :
  • int arr[] = int [5] new

Which of these coding types is used for data type characters in Java?

Answer :
  • UNICODE

Which of these values can a boolean variable contain?

Answer :
  • True & False

Which one is a valid declaration of a boolean?

Answer :
  • boolean b3 = false;

What will be the output of the following Java program? class mainclass { public static void main(String args[]) { boolean var1 = true; boolean var2 = false; if (var1) System.out.println(var1); else System.out.println(var2); } }

Answer :
  • TRUE

Which of these can not be used for a variable name in Java?

Answer :
  • keyword

Choose the statement(s) true about swith statement? A) switch expression supports only for primitive types B) Default options must be the last case in switch and does not require break statement C) switch expression supports only intgral and enumerated types D) mulitple case with same constant values gives compilation error

Answer :
  • AD