Search Header Logo

Java Programming Practice Questions

Authored by THRUPAWAI Moe

Computers

University

Used 3+ times

Java Programming Practice Questions
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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

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