Search Header Logo

java quiz 2

Authored by Ms. IT

University

Used 11+ times

java quiz 2
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

class Test {

public static void main(String[] args) {

for(int i = 0; 1; i++) {

System.out.println("Hello");

break;

}

}

}

Compiler Error

hello

garbage value

0 1

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

lass Test {

public static void main(String[] args) {

for(int i = 0; true; i++) {

System.out.println("Hello");

break;

}

}

}

compilation error

Hello

all the above

none of the above

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

class Test {

private static int x;

public static void main(String args[]) {

System.out.println(fun());

}

static int fun() {

return ++x;

}

}

0

2

1

3

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class Test

{

public static void main(String[] args)

{

int value = 3, sum = 6 + -- value;

int data = --value + ++value / sum++ * value++ + ++sum % value--;

System.out.println(data);

}

}

1

2

0

3

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

public class Test

{

public static void main(String[] args)

{

int temp = 9;

int data = 8;

System.out.println(temp & data);

}

}

9

8

1000

1001

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import java.util.*;

public class Test {

public static void main(String[] args)

{

int[] x = new int[3];

System.out.println("x[0] is " + x[0]);

}

}

The program has a compile error because the size of the array wasn’t specified when declaring the array.

The program has a run time error because the array elements are not initialized.

The program runs fine and displays x[0] is 0.

The program has a run time error because the array element x[0] is not defined.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

import java.util.*;

public class Test {

public static void main(String[] args)

{

int[] x = { 120, 200, 016 };

for (int i = 0; i < x.length; i++)

System.out.print(x[i] + " ");

}

}

120 200 16

120 200 14

120 200 016

016 is a compile error. It should be written as 16.

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?