Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Programming Language.

Total questions: 45

Worksheet time: 23mins

Name
Class
Date
1.

Java is a ________, object-oriented, and platform-independent programming language developed by Sun Microsystems in 1995 (now owned by Oracle).

a)

high-level

b)

low-level

c)

machine-level

d)

assembly-level

2.

Who developed Java in 1995?

a)

Microsoft

b)

Sun Microsystems

c)

Oracle

d)

IBM

3.

Java is designed to be simple, secure, and portable, following the principle of "write once, run anywhere" through the use of the ________.

a)

Java Virtual Machine (JVM)

b)

Java Development Kit (JDK)

c)

Java Runtime Environment (JRE)

d)

Java Compiler

4.

The principle of "write once, run anywhere" in Java means:

a)

Java programs can run on any platform without modification.

b)

Java code must be rewritten for each operating system.

c)

Java applications only run on Windows systems.

d)

Java programs require platform-specific compilers.

5.

Which programming concepts does Java support that make it suitable for building modular and reusable code?

a)

Procedural programming concepts

b)

Object-oriented programming concepts

c)

Functional programming concepts

d)

Logic programming concepts

6.

Fill in the blank: Java is widely used in ________, web development, enterprise systems, mobile apps (Android), and cloud-based solutions.

a)

desktop applications

b)

game consoles

c)

smart TVs

d)

wearable devices

7.

What are some reasons for Java's popularity according to the passage?

a)

Robust standard libraries, automatic memory management (garbage collection), and strong community support

b)

Limited libraries, manual memory management, and weak community support

c)

Complex syntax, slow performance, and poor documentation

d)

Lack of versatility and reliability

8.

Fill in the blank: One of the key features of Java is that it is ________ & Easy to Learn.

a)

Simple

b)

Complicated

c)

Obscure

d)

Difficult

9.

Fill in the blank: Java is ________-Oriented and supports classes, inheritance, polymorphism, etc.

a)

Object

b)

Procedure

c)

Function

d)

Logic

10.

Fill in the blank: Java is ________-Independent and runs on Windows, Mac, Linux, Android, etc.

a)

Platform

b)

Language

c)

Device

d)

Network

11.

Fill in the blank: Java is Secure & ________ and provides automatic memory management and strong typing.

a)

Robust

b)

Fragile

c)

Unstable

d)

Weak

12.

Fill in the blank: Java is ________ and supports concurrent programming.

a)

Multithreaded

b)

Single-threaded

c)

Non-threaded

d)

Unthreaded

13.

Refer to the Java 'Hello World' program shown in the image. What will be the output when this program is executed?

a)

A) Hello, World!

b)

B) Hello World

c)

C) HelloWorld

d)

D) Error

14.

Refer to the Java 'Hello World' program shown in the image. The programming language used in the code is:

a)

Java

b)

Python

c)

C++

d)

JavaScript

15.

Fill in the blank: Data types define the kind of ______ a variable can store.

a)

data

b)

function

c)

loop

d)

operator

16.

In Java, every variable must be declared with a data type.

a)

True

b)

False

17.

What are the two main categories of data types in Java?

a)

Primitive and Non-Primitive (Reference)

b)

Integer and String

c)

Static and Dynamic

d)

Local and Global

18.

Fill in the blank: The two main categories of data types in Java are ______ Data Types and Non-Primitive (Reference) Data Types.

a)

Primitive

b)

Object-Oriented

c)

Composite

d)

Functional

19.

What is the range of values for the 'byte' data type in Java?

a)

-128 to 127

b)

0 to 255

c)

-255 to 255

d)

-127 to 128

20.

Primitive types are the basic building blocks in Java. They store simple values directly in memory. Which primitive data type in Java is a 16-bit integer?

a)

byte

b)

short

c)

int

d)

long

21.

Primitive types are the basic building blocks in Java. They store simple values directly in memory. Which primitive data type is most commonly used for 32-bit integers in Java?

a)

byte

b)

short

c)

int

d)

long

22.

Primitive types are the basic building blocks in Java. They store simple values directly in memory. Which primitive data type in Java is used for big numbers and is a 64-bit integer?

a)

byte

b)

short

c)

int

d)

long

23.

Primitive types are the basic building blocks in Java. They store simple values directly in memory. Which primitive data type in Java is a 32-bit decimal and stores approximate values?

a)

float

b)

double

c)

int

d)

long

24.

Classes & Objects are ________ data types.

a)

user-defined

b)

primitive

c)

built-in

d)

abstract

25.

Which of the following is NOT an example of a non-primitive data type?

a)

String

b)

Array

c)

Integer

d)

Classes & Objects

26.

Non-primitive data types store references to memory locations.

a)

True

b)

False

27.

Unlike primitive types, non-primitives can have ________ and are created using constructors.

a)

methods

b)

values

c)

loops

d)

keywords

28.

What is a variable?

a)

A variable is a name given to a memory location that stores data.

b)

A variable is a type of function that performs calculations.

c)

A variable is a fixed value that cannot be changed.

d)

A variable is a graphical representation of data.

29.

Fill in the blank: A ________ is a name given to a memory location that stores data.

a)

variable

b)

function

c)

operator

d)

constant

30.

How can you think of a variable?

a)

Like a box with a label where you can keep values.

b)

Like a locked door that cannot be opened.

c)

Like a number that never changes.

d)

Like a finished book that cannot be edited.

31.

In Java, every variable has a ______ (what kind of data it can hold).

a)

type

b)

method

c)

class

d)

object

32.

Which of the following is a valid way to begin a variable name according to the rules for naming variables?

a)

With a number

b)

With a letter

c)

With a space

d)

With a reserved keyword

33.

A variable name can start with a number according to the rules for naming variables.

a)

True

b)

False

34.

Fill in the blank: According to the rules for naming variables, you should use ________ for variable names (e.g., studentName, accountBalance).

a)

camelCase

b)

snake_case

c)

PascalCase

d)

kebab-case

35.

Which of the following is NOT allowed in variable names according to the rules for naming variables?

a)

Spaces

b)

camelCase

c)

Letters

d)

Underscore (_)

36.

In Java, you must declare a variable before using it.

a)

True

b)

False

37.

Fill in the blank with the correct syntax for declaring a variable in Java: ______ variableName = value;

a)

dataType

b)

varType

c)

typeOf

d)

variableType

38.

What is the value assigned to the variable 'age' in the following declaration?

a)

20

b)

18

c)

25

d)

30

39.

What is the data type of the variable 'height' in the following declaration?

a)

double

b)

int

c)

char

d)

float

40.

Is the following variable declaration syntactically correct in Java? #String name = "Ama";

a)

True

b)

False

41.

Which of the following Java code snippets correctly stores your name, age, and GPA, and prints them using System.out.println()?

a)

String name = "John"; int age = 20; double gpa = 3.5; System.out.println(name + " " + age + " " + gpa);

b)

String name = 20; int age = "John"; double gpa = "3.5"; System.out.println(name + age + gpa);

c)

String name = "John"; int age = 20; double gpa = 3.5; System.out.print(name, age, gpa);

d)

String name = "John"; int age = 20; double gpa = 3.5; System.out.println(name, age, gpa);

42.

What are operators used for in Java?

a)

To perform operations on variables and values

b)

To store data

c)

To create classes

d)

To define methods

43.

Which of the following is NOT a type of operator supported by Java?

a)

Arithmetic

b)

Logic

c)

Comparison

d)

Assignment

e)

Inheritance

44.

Fill in the blank: Operators are ______ used to perform operations on variables and values.

a)

symbols

b)

numbers

c)

letters

d)

words

45.

Fill in the blank: One type of operator in Java is _________.

a)

Arithmetic Operators

b)

String Operators

c)

Loop Operators

d)

Array Operators