Search Header Logo

java MCQ

Authored by Kashaf Khan

Computers

University

Used 6+ times

java MCQ
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Print the output of following code snippet.

{

  int p= 5000;

  int q=2000;

while(-- p < ++ q);

System.out.println(p);

}

a) 4999

5000

4989

4888

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

 public class XYZ

{

  public static void main(String[] args)

{

  short x = 50, Y;

  Y = x * 100;

  System.out.print(y);

  }

}

1

Run time error

5000

Compile time error

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class XYZ

 {

  public static void main(String[] args) {

  String str = "GLBAJAJ";

  str = "GLBIAN";

  System.out.println(str);

  }

}

"GLBAJAJ"

GLBIAN

GLBIAN"

GLBIAN

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

 public class XYZ {

  public static void main(String arg[]) {

  int i;

  for (i = 1; i <= 12; i += 2) {

  if (i == 8) {

  System.out.println(i);

  break;

  }

  }

  }

}

A. No output

2

23232

121

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the purpose of the instanceof operator?

Check if an object is an instance of a specific class or interface

Compare two object references

Check if an object is an instance of a specific class or interface

Multiply instances

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

 Print the output of following code snippet.

{

  int p= 5000;

  int q=2000;

while(-- p < ++ q)

System.out.println(p);

}

a) No any output

a) Compile time error

a) Run time error

0

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which method in java is used to generate random numbers in Java?

random.nextInt()

random()

rand()

All of these

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