Data Types and Variables
Control Flow (if/else, loops)
Arrays and ArrayLists
Methods / Functions
Object-Oriented Programming (OOP)
100

What is the default value of an int variable in Java?

0

100

How many times will a for (int i = 0; i < 5; i++) loop run?

5

100

How do you declare an empty array of 10 integers?

int[] arr = new int[10];

100

What is the correct syntax for defining a method that returns an int?

public int methodName() { }

100

What keyword is used to create a new object?

new

200

Which data type would you use to store a true/false value?

boolean

200

What is the difference between == and .equals() when comparing objects?

== checks the memory address, while .equals() checks the values in the object.

200

What is the index of the first element in an array?

0

200

What does the return statement do inside a method?

Ends the method and sends a value back.

200

What is the purpose of a constructor?

To initialize an object’s fields when it is created.

300

What is the result of 5/2 in Java?

2 (integer division)

300

What is the difference between a for loop and a while loop?

Answers vary. (Generally, a for loop is for a known number of iterations, while a while loop is for until a condition is reached)

300

How do you access the last element of an array named arr?

arr[arr.length - 1]

300

Can a method have more than one parameter?

Yup

300

What does this refer to inside a class?

The current object instance.

400

How would you declare a variable to store a single character?

char varName = 'A';

400

What keyword immediately stops a loop?

break

400

Which method adds an element to an ArrayList?

.add(element)

400

What is method overloading?

Defining multiple methods with the same name but different parameter lists.

400

How do you call a method from an object you created? (In terms of the object name)

objectName.methodName();

500

What is the result of: true && false || true?

true

500

What does the continue keyword do inside a loop?

Skips the rest of the loop and moves to the next iteration.

500

What happens if you try to access an array index that doesn't exist?

You get an ArrayIndexOutOfBoundsException.

500

What is the difference between a method’s return type and its parameters?

The return type specifies what value the method gives back after execution. Parameters are inputs passed into the method to customize its behavior.

500

What is the difference between a class and an object in Java?

A class is a blueprint or template that defines the structure and behavior of objects. An object is an instance of a class, created using the new keyword.

M
e
n
u