Java syntax

Java syntax

University

20 Qs

quiz-placeholder

Similar activities

Logic Based Testing

Logic Based Testing

University

15 Qs

Java Control and Loop -2

Java Control and Loop -2

University

20 Qs

Lenguaje de Definición de Datos

Lenguaje de Definición de Datos

University

18 Qs

JAVA - Arrays

JAVA - Arrays

University - Professional Development

15 Qs

PBO Inheritance Episode 2

PBO Inheritance Episode 2

University

18 Qs

Logika & Pemrograman (ID)

Logika & Pemrograman (ID)

10th Grade - Professional Development

20 Qs

DBC CHAPTER 3 - REVISION

DBC CHAPTER 3 - REVISION

University

15 Qs

CN_Minor2

CN_Minor2

University

20 Qs

Java syntax

Java syntax

Assessment

Quiz

Computers

University

Practice Problem

Easy

Created by

Wayground Content

Used 3+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What symbol is used to end a Java statement?

.

;

:

!

Answer explanation

Java statements end with a semicolon (;).

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

How many primitive data types does Java have?

6

7

8

9

Answer explanation

Java has 8 primitive data types: byte, short, int, long, float, double, char, and boolean.

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What happens if a local int variable is used without initialization?

It is initialized to 0.

It retains a garbage value.

It causes a compilation error.

It is initialized to -1.

Answer explanation

"Local variables in Java must be explicitly initialized before use, as they do not have default values. Attempting to use an uninitialized local variable results in a compilation error.

4.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What is the size of the 'int' data type in Java?

2 bytes

4 bytes

8 bytes

16 bytes

Answer explanation

The 'int' data type in Java occupies 4 bytes (32 bits).

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What will this print?
int x = 5; int y = 3; System.out.println(x - y);

1

2

3

4

Answer explanation

The difference between x (5) and y (3) is 2.

6.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Identify the error in this code:
int num; System.out.println(num);

Variable not initialized

Syntax error in declaration

Variable out of scope

Data type mismatch

Answer explanation

Local variables like num must be explicitly initialized before use.

7.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What is the output of this code? System.out.println("Java " + "Programming");

Java Programming

Java & Programming

JavaProgramming

Programming in Java

Answer explanation

The + operator concatenates the two strings, resulting in Java Programming.

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?