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
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
0 of 19 Questions completed
Questions:
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:
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 |
|
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
Which is the correct way to write a comment in Java?
(one or more answers)
Which is the correct way to write a multi line comment in Java?
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);
}
}
}
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);
}
}
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);
}
}
Which is the correct way to print a new line in Java?
Which is the correct way to print a horizontal tab line in Java?
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);
}
}
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);
}
}
Multiple inheritance is supported in Java?
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);
}
}
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);
}
}
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));
}
}
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));
}
}
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));
}
}
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);
}
}
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]);
}
}
}
}
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());
}
}
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);
}
}
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-advertisement | 1 year | Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Advertisement" category . |
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
CookieLawInfoConsent | 1 year | Records the default button state of the corresponding category & the status of CCPA. It works only in coordination with the primary cookie. |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Cookie | Duration | Description |
---|---|---|
_gat | 1 minute | This cookie is installed by Google Universal Analytics to restrain request rate and thus limit the collection of data on high traffic sites. |
Cookie | Duration | Description |
---|---|---|
_ga | 2 years | The _ga cookie, installed by Google Analytics, calculates visitor, session and campaign data and also keeps track of site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognize unique visitors. |
_gid | 1 day | Installed by Google Analytics, _gid cookie stores information on how visitors use a website, while also creating an analytics report of the website's performance. Some of the data that are collected include the number of visitors, their source, and the pages they visit anonymously. |
tk_lr | 1 year | The tk_lr is a referral cookie set by the JetPack plugin on sites using WooCommerce, which analyzes referrer behaviour for Jetpack. |
tk_or | 5 years | The tk_or is a referral cookie set by the JetPack plugin on sites using WooCommerce, which analyzes referrer behaviour for Jetpack. |
tk_r3d | 3 days | JetPack installs this cookie to collect internal metrics for user activity and in turn improve user experience. |
tk_tc | session | JetPack sets this cookie to record details on how user's use the website. |
Cookie | Duration | Description |
---|---|---|
m | 2 years | No description available. |