UnicMinds

Java Quiz for Students

Java Quiz for Early Teens

The quiz has multiple choice questions and programming questions. The topics covered are: Classes and Objects in Java, Variables and Datatypes in Java, Methods in Java, User Input in Java, & Formatting Output in Java

Question 1:

What will be the output of the following program?

public class Main

{   

public static void main(String[] args) {

String str = “1234”;

int a =int(str);

System.out.println(a);

}

}

  1. 123
  2. 1234
  3. 12340
  4. Compilation Error

Question 2:

What is the return type of a method that does not return any value?

a) int

b) float

c) void

d) double

Question 3:

Which of the following is a method having the same name as that of its class?

a) finalize

b) delete

c) class

d) constructor

Question 4:

Which method can be defined only once in a program?

a) main method

b) finalize method

c) static method

d) private method

Question 5:

What will be the output of the following program?

class Main {

  public static void main(String args[]) {

    float f = 5.25f;

    double d = 5.25

    System.out.println(f == d);

  }

}

  1. True 
  2. False

You may like to read: Difficult PSLE Math Questions, Block Coding Quiz for Kids, & Scratch Coding Quiz for Kids

Leave a Comment

Your email address will not be published. Required fields are marked *

BOOK A FREE TRIAL