Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Fundamentals

Total questions: 24

Worksheet time: 22mins

Name
Class
Date
1.

Reorder the following Java program structure

a)

package helloworld;

b)

public class HelloWorld{

c)

public static void main (String [ ] args) {

d)

System.out.println("Hello World from Java");

e)

}

}

1)
2)
3)
4)
5)
2.

Organize these options into the right categories

Categorize the following

+

-

*

/

%

+=

-=

*=

/=

%=

==

>

<

<=

>=

!=

&&

||

!

++

Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
3.

Drag the following missing parts of for loop to its correct place in order to display numbers from 1 to 10. for ( ​ (a)   x<=10;​ (b)   ){

System.​ (c)   println(​ (d)   )​ (e)  

Choose from the below words
out.
x
;
int x=1;
x++;
4.

Match the following

a)
int
1.

5

b)
float
2.

5.2

c)
char
3.

'a'

d)
String
4.

"abc"

e)
boolean
5.

true

5.

Print "Hello World" if x is greater than y.

​ (a)   x​ (b)   50 ​ (c)   y = 10;

​ (d)   (x​ (e)   y) {

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

}

Choose from the below words
,
int
=
if
>
6.

Insert the missing parts to complete the following switch statement. (a)   day = 2;

switch (​ (b)   ) {

​ (c)   1: System.out.println("Saturday");

​ (d)  

case ​ (e)   : System.out.println("Sunday");

break;

}

Choose from the below words
case
2
break;
day
int
7.

Who invented Java Programming?

a)
Steve Jobs
b)
Mark Zuckerberg
c)
Bill Gates
d)
James Gosling
8.

What is the main aim of OOP?

a)
To structure and organize complex code using objects and classes.
b)
To increase code duplication and redundancy.
c)
To eliminate the need for classes and objects.
d)
To make code more confusing and difficult to understand.
9.

What are the advantages of using OOP?

a)

It helps in structuring and organizing complex code using objects and classes.

b)

It increases code duplication and redundancy.

c)

It eliminates the need for classes and objects.

d)

It makes code more confusing and difficult to understand.

10.

What is encapsulation in OOP?

a)

It is a process of hiding the internal details of an object and providing access only through public methods.

b)

It is a process of exposing the internal details of an object and providing direct access to its properties.

c)

It is a process of creating multiple instances of an object.

d)

It is a process of defining the structure and behavior of an object.

11.

What is inheritance in OOP?

a)

It is a process of hiding the internal details of an object and providing access only through public methods.

b)

It is a process of exposing the internal details of an object and providing direct access to its properties.

c)

It is a process of creating multiple instances of an object.

d)

It is a process of acquiring properties and behaviors from a parent class.

12.

Which access specifier allows a method to be accessible in all classes?


a)
default
b)
public
c)
protected
d)
private
13.

What is the purpose of a method body?

a)
To store the input parameters of the method
b)
To contain the code that defines the behavior of the method
c)
To define the return type of the method
d)
To specify the access modifiers of the method
14.

What is the purpose of data abstraction in OOP?

a)
To reveal internal details and hide necessary information and functionality.
b)
To expose both internal details and necessary information and functionality.
c)
To hide all details and expose no information or functionality.
d)
To hide internal details and expose necessary information and functionality.
15.

What is an object?

a)
An object is a mathematical equation.
b)
An object is a data structure that contains properties and methods.
c)
An object is a type of animal.
d)
An object is a programming language.
16.

What is a class?

a)
A class is a keyword in programming languages.
b)
A class is a blueprint for creating objects.
c)
A class is a function in object-oriented programming.
d)
A class is a type of data structure.
17.

What is the difference between a class and an object?

a)
A class and an object are the same thing.
b)
A class is a specific type of object.
c)
A class is used to store data, while an object is used to perform actions.
d)
A class is a blueprint or template for creating objects, while an object is an instance of a class.
18.

What is polymorphism?

a)
Ability of an object to take on many forms
b)
Ability of an object to change its type
c)
Ability of an object to take on multiple shapes
d)
Ability of an object to have multiple behaviors
19.

What is a try/ catch block?

a)
A try/catch block is used to define a loop in programming languages.
b)
A try/catch block is a type of data structure in programming languages.
c)
A try/catch block is a mechanism in programming languages that allows for the handling of exceptions or errors.
d)
A try/catch block is a way to declare variables in programming languages.
20.

Which statement is true about Java?

a)
Java is a low-level programming language.
b)
Java is primarily used for web development.
c)
Java is not an object-oriented programming language.
d)
Java is a high-level programming language that is widely used for developing applications and software.
21.

Which component is used to compile, debug and execute the java programs?

a)
Java Development Kit (JDK)
b)
Java Virtual Machine (JVM)
c)
Java Runtime Environment (JRE)
d)
Java Compiler (JC)
22.

Reorder the following java operators according to its precedence.

a)

()

b)

++

c)

*

d)

+

e)

&&

1)
2)
3)
4)
5)
23.

Match the following data type based on its description.

a)
int
1.

store whole numbers

b)
float
2.

Stores fractional numbers

c)

char

3.

Stores a single character/letter

d)

boolean

4.

Stores true or false values

e)

array

5.

collection of elements

24.

Type your full name:

4 lines