Search Header Logo

Java Variables Quiz

Authored by Trainer Mike

Other

12th Grade

Used 1+ times

Java Variables Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

25 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a valid way to declare a variable in Java?

int number = 10;

All of the above

var number = 10;

Integer number = 10;

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? public class Calculate { public static void main(String[] args) { int a; System.out.println(a); } }

0

Compilation Error

Runtime Error

Undefined Behavior

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is true about variable names in Java?

Variable names can start with a number

Variable names can contain special characters like @ or #

Variable names are case-sensitive

Variable names can be a Java keyword

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the default value of a boolean instance variable in Java?

Compilation Error

null

false

true

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Java program? public class Main { static int x; public static void main(String[] args) { System.out.println(x); } }

Runtime Error

0

Compilation Error

Undefined Behavior

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to declare a constant variable in Java?

const int MAX = 100;

final int MAX = 100;

int const MAX = 100;

MAX = 100;

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of this code? public class Example { int num = 5; public static void main(String[] args) { Example obj = new Example(); System.out.println(obj.num); } }

Undefined Behavior

5

Compilation Error

Runtime Error

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?