Java Programming Practice Questions

Java Programming Practice Questions

University

15 Qs

quiz-placeholder

Similar activities

Java Methods and Constructors

Java Methods and Constructors

University

10 Qs

ROUND 3

ROUND 3

University

10 Qs

UAS Praktikum: Logika dan Algoritma Pemrograman

UAS Praktikum: Logika dan Algoritma Pemrograman

1st Grade - University

10 Qs

No Strings Attached

No Strings Attached

University

20 Qs

Python Quiz - 1

Python Quiz - 1

University

10 Qs

String manipulation and Encapsulation

String manipulation and Encapsulation

University

15 Qs

Day 3 {C} Quiz

Day 3 {C} Quiz

University

10 Qs

Latihan1

Latihan1

University

10 Qs

Java Programming Practice Questions

Java Programming Practice Questions

Assessment

Quiz

Computers

University

Medium

Created by

THRUPAWAI Moe

Used 3+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

int a = 5, b = 7; System.out.println("Result: " + (a++ + ++b));

Result: 12

Result: 13

Result: 14

Result: 15

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method will correctly determine if two String variables, str1 and str2, contain the exact same sequence of characters?

str1 == str2

str1.equals(str2)

str1.compareTo(str2)

str1.match(str2)

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Identify the incorrect statement regarding constructors in Java.

Constructors must have the same name as the class.

Constructors can return any type.

Constructors can be overloaded.

Constructors are used to initialize objects.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

boolean flag = true; if (flag == false) { System.out.println("False"); } else { System.out.println("True"); }

False

True

Compilation Error

Runtime Error

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which keyword in Java is used to prevent method overriding?

static

final

void

private

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Choose the correct way to declare and initialize a one-dimensional integer array.

int arr[] = new int[];

int arr[5] = {1,2,3,4,5};

int[] arr = new int[]{1,2,3,4,5};

int arr = {1,2,3,4,5};

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which access modifier restricts access only within its own class?

public

protected

private

default

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?