Search Header Logo

JP-Quiz-1

Authored by Jeena KK

Computers

University

Used 1+ times

JP-Quiz-1
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

18 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

String og = "helloworld";

String og2 = new String(og);

System.out.println((og==og2) + " "+ (og.equals(og2)));

true true

true false

false true

false false

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

int five = 5;

int two = 2;

int total = five + (five > 6 ? ++two : --two);

1

2

4

6

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which one is not a valid statement in Java?

double num = 2.718;

double num = 2._718;

double num = 2.7_1_8;

double num = 2.718;

double num = 2._718;

double num = 2.7_1_8;

none

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How many strings can be collected by Garbage Collector in the following code snippet?

public static void main(String[] fruits) {

String str1 = new String("open");

String str2 = new String("source");

String str2 = new String("opengenus");

str3 = str1;

str2 = str3;

str1 = str2;

}

0

1

2

3

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What line in this code snippet will give compilation error?

double d1 = 5f; // c1

double d2 = 5.0; // c2

float f1 = 5f; // c3

float f2 = 5.0; // c4

c1

c2

c3

c4

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following code snippet?

public static void main(String... args) {

String car, bus = "petrol";

car = car + bus;

System.out.println(car); }

petrol

petrolpetrol

Compilation error

Runtime error

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which code statement give compilation error?

double num1, int num2 = 1; // C1

int num1, num2; // C2

int num1, num2 = 1; // C3

int num1 = 2, num2 = 1; // C4

c1

c2

c3

c4

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?