Skip to content
J2J Institute
Search
K
Main Navigation
Home
Jobs
Courses
Java
Core
Advanced
Python
SQL
PowerBI
Testing
Manual
Automation
Interview Questions
Java
Python
SQL
Manual
Automation
Quiz
Java
Python
SQL
Appearance
Menu
Return to top
On this page
Beginner level java quiz
What is the correct syntax for the main method in Java?
public static void main(String[] args)
public void main(String[] args)
static public void main(String[] args)
void main(String[] args)
Which of the following is not a valid data type in Java?
int
float
double
decimal
What is the output of the following code? System.out.println(10 + 20 + "Java");
Java30
30Java
Java
1020Java
Which keyword is used to define a constant in Java?
static
final
const
constant
What will be the output of the following code? int x = 5; int y = 10; System.out.println(x == y);
true
false
5
10
What is the default value of a boolean variable in Java?
true
false
0
null
Which of these is used to create an instance of a class in Java?
new
class
object
this
What does the break statement do in a loop?
Exits the current loop
Skips the current iteration and continues to the next
Terminates the program
Pauses the loop
Which of the following is true about Java arrays?
Arrays in Java can have elements of different types
Arrays are fixed in size once declared
Arrays cannot be resized
Both b and c are correct
What is the purpose of the public keyword in Java?
To specify that the method or class can only be accessed within the same package
To allow the method or class to be accessed from anywhere
To make the method or class private
To prevent the method or class from being inherited
Submit