Alien head

Basic Java Programming Quiz

Description: Basic Java Programming Quiz
Number of Questions: 10
Created by:
Tags: java

What is the size of a Char?

  1. 4 bits

  2. 7 bits

  3. 8 bits

  4. 16 bits

Answer: 4

A class cannot be declared:

  1. Static

  2. Private

  3. Default

Answer: 2

Following code will result in: int a = 3.5;

  1. Compilation error

  2. Runtime error

  3. a being 3.5

  4. a being 3.

Answer: 1

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

  1. Compilation error

  2. Runtime error

  3. No errors

Answer: 3

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

Answer: 3

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

Answer: 3

A class can be transient

  1. True

  2. False

Answer: 2

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

Answer: 1

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

Answer: 1

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

Answer: 3
+ View questions