GoCoding.org

Java Quiz

by | Nov 19, 2022 | Assessment, Interview

0

Java Quiz

An MCQ Quiz for Java Interviewers

1 / 30

What is the purpose of implementing keywords?

2 / 30

Which of the code will print output 10?

3 / 30

What will be the output of the code below? public class Main {
public static void main(String[] args) {
final int myNumber = 30;
myNumber = 28;
System.out.println(myNumber);
}
}

4 / 30

What is the function of mkdir () method?

5 / 30

Which of these are enum constants?

6 / 30

Which package allows us to work with files?

7 / 30

What will be the output of the code below? public class Main {
public static void main(String[] args) {
String r = "21";
int s = 11;
String t = r + s;
System.out.println(t);
}
}

8 / 30

Java HashSet can be used for

9 / 30

What will be the output of the code below? public class Main {
public static void main(String[] args) {
int x = 9;
int y = 2;
System.out.println(x == y);
}
}

10 / 30

What is another word for iterator?

11 / 30

What will be the output of the below code? public class Main {
public static void main(String[] args) {
int m = 7;
int n = 3;
System.out.println(m % n);
}
}

12 / 30

What is the function of this "s" meta character in java?

13 / 30

What will be the output of the below code?
public class Main {
public static void main(String[] args) {
long myNumber = 180000000L;
System.out.println(myNumber);
}
}

14 / 30

How can we import regular expressions in java?

15 / 30

In the code below, in which part is the constructor created? public class Main {
int p;
public Main() {
p = 29;
}
public static void main(String[] args) {
Main myObj = new Main();
System.out.println(myObj.p);
}
}

16 / 30

Why Alive() method is used?

17 / 30

What will be the output of the following code? public class Main {
static int myMethod(int p) {
return 10 + p;
}

public static void main(String[] args) {
System.out.println(myMethod(7));
}
}

18 / 30

A java threads

19 / 30

The below code is an example of? public class Main {
public static void main(String[] args) {
int result = sum(10);
System.out.println(result);
}
public static int sum(int k) {
if (k > 0) {
return k + sum(k - 1);
} else {
return 0;
}
}
}

20 / 30

A ________ is a block of code that takes in a parameter and returns a value and is similar to methods.

21 / 30

Which of the following code will print output as "I live in London"?

22 / 30

Which of the following are types of casting in java?

23 / 30

What will be the output of below code? public class Main {
public static void main(String[] args) {
String[] fruits = {"mango", "apple", "banana", "watermelon"};
fruits[0] = "kiwi";
System.out.println(fruits[0]);
}
}

24 / 30

What are examples of primitive data types?

25 / 30

What will be the output of following code? public class Main {
public static void main(String[] args) {
for (int i = 0; i < 7; i++) { if (i == 3) { continue; } System.out.println(i); } } }

26 / 30

What will be the output of following code? public class Main {
public static void main(String[] args) {
String txt = "My name is Julie";
System.out.println("The length of the string is: " + txt.length());
}
}

27 / 30

What is the correct naming of variables in java?

28 / 30

The below code is an example of? public class Main {
public static void main(String[] args) {
int myInt = 7;
double myDouble = myInt;

System.out.println(myInt);
System.out.println(myDouble);
}
}

29 / 30

Which of the following code will print output as "John Doe"?

30 / 30

Java is programming language in which every line of code must be inside a ___________.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisement

Advertisement

Advertisement

Advertisement