Java syntax

Java syntax

University

20 Qs

quiz-placeholder

Similar activities

GPS

GPS

9th Grade - University

15 Qs

1ºDAM/DAW - Entornos de Desarrollo - UD1-6 - Prof. C. Boni

1ºDAM/DAW - Entornos de Desarrollo - UD1-6 - Prof. C. Boni

University - Professional Development

20 Qs

basisdata1

basisdata1

University

20 Qs

Memory-Mobo-Hard/Software

Memory-Mobo-Hard/Software

University

18 Qs

Test

Test

KG - University

25 Qs

PARC Linux Basic Part 2

PARC Linux Basic Part 2

University

20 Qs

SQL Quiz

SQL Quiz

University

18 Qs

CORLANG Week6-7

CORLANG Week6-7

10th Grade - 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.

Create a free account and access millions of resources

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?