0
Alien head

Basic Java Programming Quiz

Description: Basic Java Programming Quiz
Number of Questions: 10
Created by:
Tags: java
Attempted 0/10 Correct 0 Score 0

What is the size of a Char?

  1. 4 bits

  2. 7 bits

  3. 8 bits

  4. 16 bits


Correct Option: D

A class cannot be declared:

  1. Static

  2. Private

  3. Default


Correct Option: B

Following code will result in: int a = 3.5;

  1. Compilation error

  2. Runtime error

  3. a being 3.5

  4. a being 3.


Correct Option: A

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

  1. Compilation error

  2. Runtime error

  3. No errors


Correct Option: C

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


Correct Option: C

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


Correct Option: C

A class can be transient

  1. True

  2. False


Correct Option: B

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


Correct Option: A

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


Correct Option: A

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


Correct Option: C
+ View questions