wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Q2 CT G1

Total questions: 47

Worksheet time: 49mins

Name
Class
Date
1.

Who is widely recognized as the “father of Java”?

a)

Bill Gates

b)

James Gosling

c)

Steve Jobs

d)

Dennis Ritchie

2.

What was Java originally designed for?

a)

Desktop applications

b)

Mobile games

c)

Interactive television

d)

Banking systems

3.

The principle “Write Once, Run Anywhere” (WORA) is made possible by:

a)

Source code

b)

Bytecode and JVM

c)

IDEs like NetBeans

d)

Application servers

4.

Which of the following is NOT a feature of Java?

a)

Platform independence

b)

Pointers for direct memory access

c)

Multithreading support

d)

Object-orientation

5.

JDK1 was officially released in:

a)

1989

b)

1991

c)

1996

d)

1999

6.

How did Java contribute to the rise of Object-Oriented Programming (OOP)?

a)

By replacing C++ in teaching programming

b)

By eliminating OOP features completely

c)

By using only procedural programming

d)

By creating new hardware for OOP

7.

Which of the following best explains Java’s portability?

a)

Java runs only on Windows and Linux.

b)

Java code is compiled into machine code directly.

c)

Java uses only one type of compiler for all platforms.

d)

Java bytecode can run on any JVM regardless of OS.

8.

Java is still widely used today in areas such as banking, healthcare, and e-commerce. Which TWO features best explain this continuing relevance?

a)

Platform independence and security

b)

Operator overloading and pointers

c)

Simple syntax and lack of garbage collection

d)

Proprietary frameworks only

9.

What does JDK stand for?

a)

Java Development Kernel

b)

Java Development Kit

c)

Java Deployment Kit

d)

Java Data Knowledge

10.

The JDT is specifically associated with which IDE?

a)

NetBeans

b)

IntelliJ IDEA

c)

Eclipse

d)

Visual Studio

11.

What feature of an IDE helps detect errors while coding?

a)

Syntax highlighting

b)

Garbage collection

c)

Sandbox security

d)

Operator overloading

12.

Which operator is used to find the remainder of a division in Java?

a)

/

b)

//

c)

*

d)

%

13.

What is the result of 10 / 3 in Java (using int)?

a)

3.33

b)

3

c)

4

d)

0

14.

Which relational operator returns true if two values are equal?

a)

!

b)

==

c)

<=

d)

=

15.

What is the output of (5 > 3) && (8 > 6)?

a)

TRUE

b)

FALSE

c)

8

d)

5

16.

Which operator increments a variable by 1?

a)

++

b)

--

c)

+=2

d)

**

17.

Which of the following is the correct way to declare a class in Java?

a)

public class HelloWorld { }

b)

public HelloWorld class { }

c)

Public class HelloWorld { }

d)

public class: HelloWorld { }

18.

What is the correct signature of the main method in Java?

a)

public void main(String args)

b)

public static void main{String[] args}

c)

static public void main(String args[])

d)

public static void main(String[] args)

19.

Every Java statement ends with:

a)

. (period)

b)

: (colon)

c)

; (semicolon)

d)

, (comma)

20.

Which of the following is a reserved keyword in Java?

a)

function

b)

class

c)

variable

d)

define

21.

If a file is named HelloWorld.java, which of the following must be true?

a)

The public class must be named HelloWorld.

b)

The public class must be named Hello.

c)

The class can be named anything.

d)

There is no restriction on file names.

22.

Which data type would you use to store the value 19.99 with maximum precision?

a)

String

b)

int

c)

double

d)

long

23.

Which of the following variable declarations best follows Java naming conventions?

a)

int StudentAge = 18;

b)

int studentAge = 18;

c)

int student_age = 18;

d)

int studentage = 18;

24.

You are asked to document your code for API reference. Which comment type is best used?

a)

//

b)

/*...*/

c)

/**...**/

d)

25.

Which package must be imported to use the Scanner class?

a)

java.io.Scanner;

b)

java.util.Scanner;

c)

java.lang.Scanner;

d)

java.system.Scanner;

26.

Which package contains the PrintStream class?

a)

java.io

b)

java.util

c)

java.print

d)

java.output

27.

What is the purpose of the Scanner class in Java?

a)

To write output to the console

b)

To read input from sources like keyboard, files, or strings

c)

To perform arithmetic operations

d)

To manage file permissions

28.

What does System.out.println("Hello"); do?

a)

Prints "Hello" and keeps the cursor on the same line

b)

Prints "Hello" and moves the cursor to the next line

c)

Prints Hello twice

d)

Prints Hello in bold

29.

Which method of Scanner is used to read an integer input?

a)

nextLine()

b)

nextInteger()

c)

nextInt()

d)

getInt()

30.

Which method of Scanner is used to read a String input?

a)

nextline()

b)

nextString()

c)

getLine()

d)

nextLine()

31.

What is the difference between print() and println() in Java?

a)

print() moves the cursor to the next line, println() does not

b)

println() moves the cursor to the next line, print() does not

c)

Both behave exactly the same

d)

None of the above

32.

Which statement correctly concatenates two strings for output?

a)

System.out.println("Hello" + "World");

b)

System.out.print("Hello", "World");

c)

System.out.println("Hello" - "World");

d)

System.out.concat("Hello", "World");

33.

Which of the following is the simplest decision-making statement in Java?

a)

if-else

b)

switch

c)

if

d)

else-if

34.

What will happen if the condition in an if statement evaluates to false?

a)

The program will stop

b)

The compiler shows an error

c)

The code inside the if block is executed anyway

d)

The code inside the if block is skipped

35.

Which operator is used for comparison in Java?

a)

=

b)

::=

c)

==

d)

equals

36.

What is the correct syntax of an if-else statement?

a)

if (condition); { } else { }

b)

if (condition) { } else { }

c)

if condition { } else { }

d)

if (condition) else { }

37.

What is the main purpose of the else-if ladder?

a)

To execute multiple blocks at once

b)

To check a series of conditions in order

c)

To replace loops

d)

To avoid using switch

38.

Which statement allows multiple selections in Java?

a)

switch

b)

if

c)

if else

d)

while

39.

What will happen if a semicolon is placed after the condition in an if statement?

a)

No effect

b)

Causes compilation error

c)

Ends the if statement early

d)

Makes the program run faster

40.

Which of the following data types can be used in a switch expression?

a)

float

b)

double

c)

String

d)

long

41.

Which of the following conditions is not valid in an if statement?

a)

a. a > b

b)

b. x == y

c)

c. 5

d)

d. a != b

42.

Suppose you mistakenly write if(a = 10) instead of if(a == 10). What will happen?

a)

Runtime error

b)

Prints "true"

c)

It will check equality correctly

d)

Compilation error because a = 10 is assignment

43.

What is the output of this code? int age = 20; if(age >= 18) { System.out.println("Adult"); } else { System.out.println("Minor"); }

a)

Minor

b)

Adult

c)

Error

d)

Nothing

44.

You want a program that prints "Pass" if the grade ≥ 75, otherwise "Fail". Which construct is most appropriate?

a)

if-else

b)

if-else ladder

c)

switch

d)

Nested if

45.

A teacher wants to categorize scores:
• 90 and above: Excellent

• 75-89: Passed

• Below 75: Failed

Which control structure is most appropriate?

a)

Simple if

b)

if-else

c)

if-else-if ladder

d)

switch

46.

What will be printed by this code?

int day = 2;

switch(day) {

case 1: System.out.println("Monday");

break;

case 2: System.out.println("Tuesday");

break;

case 3: System.out.println("Wednesday");

break;

default: System.out.println("Invalid day"); }

a)

Monday

b)

Tuesday

c)

Wednesday

d)

Invalid day

47.

Consider this code:
int number = 0;
if(number > 0) {

System.out.println("Positive");

} else if(number < 0) {

System.out.println("Negative");

} else {

System.out.println("Zero");

}

What is the output after execution?

a)

Positive

b)

Negative

c)

Zero

d)

Error