Basic Java Programming Quiz

Basic Java Programming Quiz

10 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the size of a Char?

  1. 4 bits
  2. 7 bits
  3. 8 bits
  4. 16 bits
Question 2 Multiple Choice (Single Answer)

A class cannot be declared:

  1. Static
  2. Private
  3. Default
Question 3 Multiple Choice (Single Answer)

Following code will result in: int a = 3.5;

  1. Compilation error
  2. Runtime error
  3. a being 3.5
  4. a being 3.
Question 4 Multiple Choice (Single Answer)

Following code will result in: int a1 = 5; double a2 = (float)a1;

  1. Compilation error
  2. Runtime error
  3. No errors
Question 5 Multiple Choice (Single Answer)

Following code will result in: int a = 9/0;

  1. Compilation error: Divisions must be in a try block.
  2. Compilation error: DivideByZeroException
  3. Runtime Exception
  4. No Error: a is NaN
Question 6 Multiple Choice (Single Answer)

Following code will result in: float a = 9/0;

  1. Compilation error: Divisions must be in a try block
  2. Compilation error: DivideByZeroException
  3. Runtime Exception
  4. No Error: a is NaN
Question 7 Multiple Choice (Single Answer)

A class can be transient

  1. True
  2. False
Question 8 Multiple Choice (Single Answer)

Following code will result in: class A { int b = 1; public static void main(String [] args) { System.out.println("b is " + b); }}

  1. Compilation error
  2. Runtime Error
  3. Runtime Exception
  4. Output of b is 1
Question 9 Multiple Choice (Single Answer)

Following code will result in: class A { public static void main(String [] args) {B b = new A(); }} class B extends A {}

  1. Compile error
  2. Runtime Exception
  3. No error
Question 10 Multiple Choice (Single Answer)

Following code will result in: class A { public static void main(String [] args) {A a = new B(); }} class B extends A {}

  1. Compiler error
  2. Runtime Exception
  3. No errors