Search Header Logo

Java Basics

Authored by satyagunadeep patta

Computers

University

Used 1+ times

Java Basics
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

31 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is JDK?

Java Development Kit

Java Distribution kit

Java Dont kit

Java Dona Kit

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? ```java System.out.println(2 + "2" + 2); ```

222
6
Error
22

Answer explanation

The first 2 is treated as a number, but when concatenated with a string "2", it becomes a string. So the final result is '222'.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output? ```java System.out.println(10 / 0); ```

Infinity
ArithmeticException
0
Compilation Error

Answer explanation

Division by zero using integers throws an ArithmeticException in Java.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following? ```java for (int i = 0; i < 3; i++) { System.out.print(i + " "); } ```

0 1 2
0 1 2 3
1 2 3
Infinite loop

Answer explanation

The loop runs while i < 3. It prints 0, 1, and 2, then stops.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of this? ```java System.out.println("5 + 5 = " + 5 + 5); ```

5 + 5 = 10
5 + 5 = 55
Error
5 + 5 = 5 + 5

Answer explanation

String concatenation happens first. "5 + 5 = " + 5 is "5 + 5 = 5", then adding another 5 gives "5 + 5 = 55".

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output? ```java System.out.println(2 * 3 + "4" + 5); ```

645
9
345
Error

Answer explanation

2 * 3 is calculated first, giving 6. Then, '6' concatenates with "4" to become "64", and finally adding 5 gives "645".

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? ```java System.out.println(2 + "2" + 2); ```

222
6
Error
22

Answer explanation

The first 2 is treated as a number, but when concatenated with a string "2", it becomes a string. So the final result is '222'.

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?

Discover more resources for Computers