Java Quizzes
Welcome to the Java Quiz challenge!
Whether you’re a seasoned Java programmer or just starting out, this platform offers a fun and interactive way to test and enhance your knowledge of the Java programming language. With a range of questions covering various topics and skill levels, this quiz is designed to help you stay up-to-date with the latest developments in Java and boost your confidence in using the language. So, buckle up and get ready to take your Java skills to the next level!
Quiz – Java Basics Part 1
The quiz contains 15 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your understanding of the basics of Java programming language: - Data types and variables - Arithmetic operators - Relational operators - Logical operators - Bitoperators - Methods
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
- Operators 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 15
1. Question
1 point(s)What is the correct syntax to output
My first Java program
?CorrectIncorrect -
Question 2 of 15
2. Question
2 point(s)How do you create a variable with a decimal value of
4.6
in Java?(one or more answers)
CorrectIncorrectHint
Float and Double data types are used to store real or floating point numbers in Java, but a Double data type is more accurate than Float. Furthermore, double is the default data type for floating point numbers.
-
Question 3 of 15
3. Question
1 point(s)Select the appropriate data type for this value:
true
CorrectIncorrect -
Question 4 of 15
4. Question
1 point(s)What is the output for "result"?
class ArithmeticOperators { public static void main(String[] args) { int a = 5; int b = 2; int c = 5; int result; result = ++a + --c * b; System.out.println(result); } }
CorrectIncorrect -
Question 5 of 15
5. Question
1 point(s)What is the output for
result?
class ArithmeticOperators { public static void main(String[] args) { int a = 5; int b = 2; int result; result = --a * b++; System.out.println(result); } }
CorrectIncorrect -
Question 6 of 15
6. Question
1 point(s)Which operator can be used to decrement a value?
CorrectIncorrect -
Question 7 of 15
7. Question
1 point(s)What is the output for
result
?class ArithmeticModulo { public static void main(String[] args) { int a = 20; int b = 7; int c = 4; int result; result = a % b % c; System.out.println(result); } }
CorrectIncorrect -
Question 8 of 15
8. Question
2 point(s)What is the output for
result
?class ArithmeticMixed { public static void main(String[] args) { int a = 10; int b = 20; int c = 5; int result; a = ++c; b = ++c; result = (a + b) % 2; System.out.println(result); } }
CorrectIncorrect -
Question 9 of 15
9. Question
1 point(s)Which operator can be used to check two values for equality?
CorrectIncorrect -
Question 10 of 15
10. Question
1 point(s)What is the output for
result
?class RelLogOperators { public static void main(String[] args) { int x = 5; int y = 6; int z = 6; boolean isSet = true; if (x < y && y >= z) { isSet = false; } System.out.println(isSet); } }
CorrectIncorrect -
Question 11 of 15
11. Question
1 point(s)What is the output for
result
?class RelLogOperators { public static void main(String[] args) { int x = 3; int y = 6; int z = 4; boolean isSet = false; if (x < z && y >= z && x > z || isSet == false) { isSet = true; } System.out.println(isSet); } }
CorrectIncorrect -
Question 12 of 15
12. Question
3 point(s)What is the output for
x
?class BitwiseOR { public static void main(String[] args) { int x, y, a = 10, b = 14, c = 2; x = a | b; System.out.println(x); } }
CorrectIncorrectHint
| = bitwise OR
a = 10 = 1010
b = 14 = 1110
x = ? -
Question 13 of 15
13. Question
3 point(s)What is the output for
y
?class BitwiseExclusiveOR { public static void main(String[] args) { int x, y, a = 10, b = 14, c = 2; y = a ^ c; System.out.println(y); } }
CorrectIncorrectHint
^= bitwise exclusive ORa = 10 = 1010c = 2 = 0010a ^ c = ? -
Question 14 of 15
14. Question
2 point(s)What is the output?
public class MethodRecursiveExample { static void fun(int val) { if (val == 20) { return; } System.out.print(val); fun(val + 2); } public static void main(String[] args) { fun(10); } }
CorrectIncorrect -
Question 15 of 15
15. Question
2 point(s)What is the output for
result
?public class Quiz { public static int fun() { return 2.5 + 10.8; } public static void main(String[] args) { System.out.println(fun()); } }
CorrectIncorrect
Quiz – Java Basics Part 2
The quiz contains 19 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your understanding of the basics of Java programming language: - Comments - Escape sequences - Data types - Operators - Control structures - Methods - Arrays
Quiz Summary
0 of 19 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 19 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 19
1. Question
2 point(s)Which is the correct way to write a comment in Java?
(one or more answers)
CorrectIncorrect -
Question 2 of 19
2. Question
1 point(s)Which is the correct way to write a multi line comment in Java?
CorrectIncorrect -
Question 3 of 19
3. Question
1 point(s)What is the output?
public class ControlStructuresQuiz { public static void main(String[] args) { int a = 4, b = 3; if (a >= b) { System.out.print(a); } else { System.out.print(b); } } }
CorrectIncorrect -
Question 4 of 19
4. Question
1 point(s)What is the output for
c
?public class ControlStructuresQuiz { public static void main(String[] args) { int a = 5, b = 8, c = 0; while (c < 11) { if (a < b) { a++; c = c + 5; } else { c = c + 4; } } System.out.print(c); } }
CorrectIncorrect -
Question 5 of 19
5. Question
1 point(s)What is the output?
public class DataTypesExample { public static void main(String[] args) { int a = 0; double b = 0.0; System.out.print(a == b ? true : false); } }
CorrectIncorrect -
Question 6 of 19
6. Question
1 point(s)Which is the correct way to print a new line in Java?
CorrectIncorrect -
Question 7 of 19
7. Question
1 point(s)Which is the correct way to print a horizontal tab line in Java?
CorrectIncorrect -
Question 8 of 19
8. Question
2 point(s)What is the output for
a
?public class OperatorQuiz extends Thread { public static void main(String[] args) { int a = 4, b = 10; while (b > a) { a++; if (a % 4 == 0) { break; } } System.out.print(a); } }
CorrectIncorrect -
Question 9 of 19
9. Question
1 point(s)What is the output for
comp
?public class StringQuiz { public static void main(String[] args) { String s1 = "hello world"; String s2 = "hello World"; boolean comp = !s1.equals(s2); System.out.print(comp); } }
CorrectIncorrect -
Question 10 of 19
10. Question
1 point(s)Multiple inheritance is supported in Java?
CorrectIncorrect -
Question 11 of 19
11. Question
1 point(s)What is the output?
public class MixedQuiz extends Thread { public static void main(String[] args) { int x = 4, y = 8, temp; temp = x; y++; temp--; x = y; y = temp; System.out.print(x + ", " + y); } }
CorrectIncorrect -
Question 12 of 19
12. Question
1 point(s)What is the output for
x
(how many loop passes)?public class OperatorQuiz extends Thread { public static void main(String[] args) { double a = 20, b = 2; int x = 0; while (a > b) { a--; b = b + 4; x++; } System.out.print(x); } }
CorrectIncorrect -
Question 13 of 19
13. Question
1 point(s)What is the output?
public class MethodsQuiz { public static int add(int a, int b) { int result; result = a + b; return result; } public static void main(String[] args) { System.out.println(add(4, 2)); } }
CorrectIncorrect -
Question 14 of 19
14. Question
1 point(s)What is the output?
public class MethodsQuiz { public static int add(int a, int b) { int result; result = a + b; return result; } public static void main(String[] args) { System.out.println(add(4.4, 2.5)); } }
CorrectIncorrect -
Question 15 of 19
15. Question
1 point(s)What is the output?
public class Cube { static int add(int x = 5) { x = 12; return x + 1; } public static void main(String[] args) { System.out.print(add(10)); } }
CorrectIncorrect -
Question 16 of 19
16. Question
1 point(s)What is the output for
currentNumber
?public class ArraysQuiz { public static void main(String[] args) { int[] numbers = { 2, 7, 12, 9, 5, 18, 10, 5, 3, 17, 15 }; int i = 0, currentNumber; currentNumber = numbers[0]; for(i = 1; i < 10; i++) { if(currentNumber < numbers[i]) { currentNumber = numbers[i]; } } System.out.print(currentNumber); } }
CorrectIncorrect -
Question 17 of 19
17. Question
2 point(s)What is the output?
public class ArraysQuiz { public static void main(String[] args) { int[][] myArray = new int[2][3]; myArray[1][0] = 4; myArray[1][1] = 5; myArray[1][2] = 8; myArray[0][0] = 1; myArray[0][1] = 8; myArray[0][2] = 7; for (int i = 0; i < myArray.length; i++) { for (int j = 0; j < myArray[i].length; j++) { System.out.print(myArray[i][j]); } } } }
CorrectIncorrect -
Question 18 of 19
18. Question
1 point(s)What is the output?
import java.util.ArrayList; public class Quiz { public static void main(String[] args) { ArrayList<Integer> myList = new ArrayList<Integer>(); myList.add(5); myList.add(8); myList.clear(); myList.add(3); myList.add(5); myList.add(9); System.out.println(myList.size()); } }
CorrectIncorrect -
Question 19 of 19
19. Question
2 point(s)What is the output?
import java.util.ArrayList; import java.util.Iterator; public class Quiz { public static void main(String[] args) { ArrayList<Integer> myList = new ArrayList<Integer>(); myList.add(1); myList.add(2); myList.add(2); myList.add(3); myList.add(4); myList.add(5); myList.add(6); myList.add(7); myList.remove(2); myList.remove(4); myList.remove(4); myList.remove(4); Iterator iter = myList.iterator(); while (iter.hasNext()) { System.out.print(iter.next() + " "); } System.out.println(myList.size() + 1); } }
CorrectIncorrect
Quiz – Java Inheritance and Polymorphism
The quiz contains 11 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your understanding of inheritance and polymorphism: - Single inheritance - Multilevel inheritance - Hierarchical inheritance - Static polymorphism - Dynamic polymorphism
Quiz Summary
0 of 11 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 11 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 11
1. Question
1 point(s)What is the output?
class Animal { public void printAnimal() { System.out.println("This is an Animal"); } }; class Dog extends Animal { public void printDog() { System.out.println("This is a Dog"); } }; class SingleInheritanceQuiz { public static void main(String[] args) { Dog obj = new Dog(); obj.printDog(); } }
CorrectIncorrect -
Question 2 of 11
2. Question
1 point(s)What is the output?
class Animal { public void printAnimal() { System.out.println("This is an Animal"); } }; class Dog extends Animal { public void printDog() { System.out.println("This is a Dog"); } }; class SingleInheritanceQuiz { public static void main(String[] args) { Dog obj = new Dog(); obj.printAnimal(); } }
CorrectIncorrect -
Question 3 of 11
3. Question
2 point(s)What is the output?
class Animal { public void printAnimal() { System.out.println("This is an Animal"); } }; class Dog extends Animal { public void printDog() { System.out.println("This is a Dog"); } }; class SingleInheritanceQuiz { public static void main(String[] args) { Animal obj = new Animal(); obj.printDog(); } }
CorrectIncorrect -
Question 4 of 11
4. Question
1 point(s)What is the output?
class Animal { public void printAnimal() { System.out.println("This is an Animal"); } }; class Dog extends Animal { public void printDog() { System.out.println("This is a Dog"); } }; class Cat extends Dog { public void printCat() { System.out.println("This is a Cat"); } }; class MultilevelInheritanceQuiz { public static void main(String[] args) { Cat obj = new Cat(); obj.printAnimal(); } }
CorrectIncorrect -
Question 5 of 11
5. Question
2 point(s)What is the output?
class Animal { public void printAnimal() { System.out.println("This is an Animal"); } }; class Dog extends Animal { public void printDog() { System.out.println("This is a Dog"); } }; class Cat extends Dog { public void printCat() { System.out.println("This is a Cat"); } }; class MultilevelInheritanceQuiz { public static void main(String[] args) { Dog obj = new Cat(); obj.printCat(); } }
CorrectIncorrect -
Question 6 of 11
6. Question
1 point(s)What is the output?
class Animal { public void printAnimal() { System.out.println("This is an Animal"); } }; class Dog extends Animal { public void printDog() { System.out.println("This is a Dog"); } }; class Cat extends Animal { public void printCat() { System.out.println("This is a Cat"); } }; class helloworld { public static void main(String[] args) { Dog obj = new Cat(); obj.printCat(); } }
CorrectIncorrect -
Question 7 of 11
7. Question
1 point(s)What is the output?
class Animal { public void printAnimal() { System.out.println("This is an Animal"); } }; class Dog extends Animal { public void printDog() { System.out.println("This is a Dog"); } }; class Cat extends Animal { public void printCat() { System.out.println("This is a Cat"); } }; class helloworld { public static void main(String[] args) { Dog obj1 = new Dog(); Cat obj = new Cat(); obj.printAnimal(); obj1.printDog(); } }
CorrectIncorrect -
Question 8 of 11
8. Question
1 point(s)What is the output?
class StaticPolymorphism { void sum(int a, int b) { System.out.println(a + b); } void sum(double a, double b, double c) { System.out.println(a + b + c); } public static void main(String[] args) { StaticPolymorphism obj = new StaticPolymorphism(); obj.sum(1, 2, 3); obj.sum(1.5, 2.5); } }
CorrectIncorrect -
Question 9 of 11
9. Question
1 point(s)What is the output?
void sum(int a, int b) { System.out.println(a + b); } void sum(double a, double b, double c) { System.out.println(a + b + c); } public static void main(String[] args) { helloworld obj = new helloworld(); obj.sum(1.5, 2.5, 3.5); obj.sum(1, 2); }
CorrectIncorrect -
Question 10 of 11
10. Question
1 point(s)Is the output the same for
a
andc
class A { void print() { System.out.println("overridden method"); } } class B extends A { void print() { System.out.println("overriding method1"); } } class C extends A { void print() { System.out.println("overriding method2"); } } public class helloworld { public static void main(String[] args) { A a = new C(); C c = new C(); a.print(); c.print(); } }
CorrectIncorrect -
Question 11 of 11
11. Question
1 point(s)Wat is the output for
a
?class A { void print() { System.out.println("overridden method"); } } class B extends A { void print() { System.out.println("overriding method1"); } } class C extends A { void print() { System.out.println("overriding method2"); } } public class helloworld { public static void main(String[] args) { A a = new B(); a.print(); } }
CorrectIncorrect
Quiz – Java Mathematical Rounding
The quiz contains 9 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your understanding of mathematical functions: - Basic mathematical functions - Mathematical rounding - Power math function - Square math function - Cubic math function
Quiz Summary
0 of 9 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 9 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 9
1. Question
1 point(s)What is the output?
public class MinMaxQuiz { public static void main(String[] args) { double min, max; int a = 12, b = 15; min = Math.min(a, b); max = Math.max(a, b); System.out.print(min + ", " + max); } }
CorrectIncorrect -
Question 2 of 9
2. Question
1 point(s)What is the output for
rounded
?public class RoundingQuiz { public static void main(String[] args) { double value = 2.41245; // Round to nearest double rounded = Math.round(value); System.out.print(rounded); } }
CorrectIncorrect -
Question 3 of 9
3. Question
1 point(s)What is the output for
rounded
?public class RoundingQuiz { public static void main(String[] args) { double value = 2.41245; // Round to nearest double rounded = Math.ceil(value); System.out.print(rounded); } }
CorrectIncorrect -
Question 4 of 9
4. Question
1 point(s)What is the output for
rounded
?public class RoundingQuiz { public static void main(String[] args) { double value = 2.41245; // Round to nearest double rounded = Math.floor(value); System.out.print(rounded); } }
CorrectIncorrect -
Question 5 of 9
5. Question
2 point(s)What is the output for
rounded
?public class RoundingQuiz { private static double roundDouble(double value, int decimalPoints) { double d = Math.pow(10, decimalPoints); return Math.round(value * d) / d; } public static void main(String[] args) { double value = 2.41245; // Round to nearest double rounded = roundDouble(value, 3); System.out.print(rounded); } }
CorrectIncorrect -
Question 6 of 9
6. Question
1 point(s)What is the output for
rounded
?public class RoundingQuiz { public static void main(String[] args) { double value = 2.41855; System.out.println(String.format("%1.6f", value)); } }
CorrectIncorrect -
Question 7 of 9
7. Question
1 point(s)What is the output for
rounded
?public class MathFunctions { public static void main(String[] args) { double power; power = Math.pow(2, 5); System.out.println("Power: " + power); } }
CorrectIncorrect -
Question 8 of 9
8. Question
1 point(s)What is the output for
rounded
?public class MathFunctions { public static void main(String[] args) { double sqrt; sqrt = Math.sqrt(169); System.out.println("Square: " + sqrt); } }
CorrectIncorrect -
Question 9 of 9
9. Question
1 point(s)What is the output for
rounded
?public class MathFunctions { public static void main(String[] args) { double cubic; // Returns the cube root of a double value. cubic = Math.cbrt(216); System.out.println("Cubic: " + cubic); } }
CorrectIncorrect
Quiz – Java Advanced
The quiz contains 8 questions and there is no time limit. You can get between 1 and 3 points for answering the questions correctly. At the end of the quiz, you'll receive a total score. You can compare yourself with other users via the leaderboard. If you achieve more than 70% you will be rewarded with a certificate. Good luck!
Test your advanced skills of the Java programming language: - Java Syntax - Advanced control structures - Classes and objects - Data abstraction - Methods
Quiz Summary
0 of 8 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 8 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 8
1. Question
1 point(s)Java is a low level programming language!
CorrectIncorrect -
Question 2 of 8
2. Question
1 point(s)Java is statically typed!
Which means the compiler or interpreter does the type checking once before the program runs or is compiled.CorrectIncorrect -
Question 3 of 8
3. Question
1 point(s)Java is a strongly-typed system!
CorrectIncorrect -
Question 4 of 8
4. Question
1 point(s)Java supports inferred typing!
CorrectIncorrect -
Question 5 of 8
5. Question
2 point(s)What is the output for
sum
?public class AdvancedControlStructure { public static void main(String[] args) { int sum = 0; for (int i = 0, j = 2; i < 5 & j < 10; i = j - i, j++) { sum += j; } System.out.print(sum); } }
CorrectIncorrect -
Question 6 of 8
6. Question
2 point(s)What is the output?
public class MethodParametersExample { static int fun(int a, int b) { if (a == 0) { return b; } else { return a + fun(a - 1, b); } } public static void main(String[] args) { System.out.print(fun(2,5)); } }
CorrectIncorrect -
Question 7 of 8
7. Question
2 point(s)What is the output?
class Test { private void privPrint() { System.out.print("A, "); } public void pubPrint() { System.out.print("B, "); } protected void protPrint() { System.out.print("C"); } } class DataAbstraction { public static void main(String[] args) { Test t1 = new Test(); t1.privPrint(); t1.pubPrint(); t1.protPrint(); } }
CorrectIncorrect -
Question 8 of 8
8. Question
1 point(s)What is the output?
class Test { private void privPrint() { System.out.print("A, "); } public void pubPrint() { System.out.print("B, "); } protected void protPrint() { System.out.print("C"); } } class DataAbstraction { public static void main(String[] args) { Test t1 = new Test(); t1.pubPrint(); t1.protPrint(); } }
CorrectIncorrect