Java Fundamentals test 2

Java Fundamentals test 2

10th Grade

22 Qs

quiz-placeholder

Similar activities

AQA GCSE Computer Science - 3.2.2 Programming Concepts

AQA GCSE Computer Science - 3.2.2 Programming Concepts

8th - 10th Grade

20 Qs

Java: Chapter 18 Exam

Java: Chapter 18 Exam

9th - 12th Grade

20 Qs

CSP Arrays

CSP Arrays

10th - 12th Grade

20 Qs

G10 | Java - Unit Test 01

G10 | Java - Unit Test 01

10th Grade

20 Qs

FOR and WHILE loop in Python

FOR and WHILE loop in Python

9th - 12th Grade

18 Qs

JavaScript Basics CodeHS

JavaScript Basics CodeHS

7th - 12th Grade

20 Qs

"switch" Java Statement - 1

"switch" Java Statement - 1

9th - 10th Grade

17 Qs

KISI-KISI PAS PEMROGRAMAN DASAR X TKJ

KISI-KISI PAS PEMROGRAMAN DASAR X TKJ

10th Grade

20 Qs

Java Fundamentals test 2

Java Fundamentals test 2

Assessment

Quiz

Computers

10th Grade

Medium

Created by

Zahra Zahid

Used 1+ times

FREE Resource

22 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What are the different data types in Java?

int, double, char, boolean, classes, interfaces, methods

float, string, byte, long, void, objects

int, double, char, boolean, classes, interfaces, arrays

int, double, char, boolean, float, string, byte

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Explain the difference between int and double data types in Java.

The main difference between int and double data types in Java is that int stores whole numbers, while double stores floating-point numbers with decimal values.

int and double are interchangeable and can be used interchangeably in Java

int is used for text data, while double is used for numerical data

int stores decimal numbers, while double stores whole numbers

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What are the different types of operators in Java?

Comparison

Equality

Shift

Unary

Arithmetic, Relational, Logical, Bitwise, Assignment, Conditional

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the use of the 'if' statement in Java?

The 'if' statement in Java is used to declare a new variable

The 'if' statement in Java is used to make a decision based on a condition.

The 'if' statement in Java is used to define a method

The 'if' statement in Java is used for looping through a set of code multiple times

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How are arrays declared and initialized in Java?

dataType arrayName = new dataType[arraySize];

Arrays in Java are declared using the syntax: arrayName = new dataType[arraySize];

dataType[] arrayName = new dataType[];

Arrays in Java are declared and initialized using the following syntax: dataType[] arrayName = new dataType[arraySize];

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the difference between 'while' and 'do-while' loops in Java?

The main difference is that the 'do-while' loop will always execute the code inside the loop at least once, regardless of the condition.

In 'do-while' loop, the condition is checked at the beginning of the loop, while in 'while' loop, the condition is checked at the end of the loop.

The 'while' loop can only be used for iterating over arrays, while the 'do-while' loop can be used for any type of iteration.

The 'do-while' loop is more efficient than the 'while' loop in terms of memory usage.

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Explain the 'for' loop in Java with an example.

Example: for(int i=1; i<=5; i++){ System.out.println(i); }

Example: for(int i=1; i<5; i++){ System.out.println(i); }

Example: for(int i=0; i<5; i++){ System.out.println(i); }

Example: for(int i=5; i>=1; i--){ System.out.println(i); }

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?