menu

Java Basics


1.

What is the output of the following code?

public class Test {
public static void main(String args[]) {
int x = 10;
int y = 5;
System.out.println(x > y);
 }
}

1

0

1

0


2.

What is the output of the following program?

public class Test {
public static void main(String args[]) {
int x = 10;
int y = x++;
System.out.println(y);
  }
}

10

11

9

None of the above


3. Which keyword is used to declare a variable in Java?

var

let

int

def


4. Which of the following is a valid way to declare a variable in Java?

int x = 5;

int 5 = x;

x = 5;

int x;


5. Which of the following is NOT a loop in Java?

while

for

do-while

if


6. Which of the following is used to create an object in Java?

class

new

object

create


7.

What is Java?

A programming language

An operating system

A database management system

A web browser


8.

What is the output of the following code?

public class Test {
public static void main(String args[]) {
int x = 5;
int y = 2;
System.out.println(x / y);
 }
}

2

2.5

2

None of the above


9.

What is the output of the following code?

public class Test {
public static void main(String args[]) {
int x = 10;
int y = 20;
System.out.println(x < y && x > 5);
 }
}

1

0

1

0


10. Which of the following is NOT a primitive data type in Java?

int

boolean

double

string