Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Put your decision-making skills to the test with this comprehensive quiz on one of Java’s most essential concepts! Whether you’re a budding coder or a seasoned developer, this engaging challenge will help you solidify your understanding of conditional statements, control the flow of your programs, and make confident coding choices.
Delve into questions that explore if statements, else clauses, nested conditions, and more. Gear up to tackle different scenarios and make Java work for you!
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)
Categories
- Not categorized 0%
- 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
class IfExample {
public static void main ( String args [ ] )
{
Scanner s = new Scanner(System.in);
int a = s.nextInt();
if(a==7) {
system.out.println(“ If statement is executed “);
}
}
}
CorrectIncorrect -
Question 2 of 15
2. Question
class IfElseSample {
public static void main ( String args [ ] )
{
String s = “ DataFlair”;
Char d [ ] = { ‘D’ , ‘a’, ‘t’, ‘a’ , ‘F’ , ‘l’ , ‘a’ , ‘i’ , ‘r’ };
String a = new String(d);
if(s.isequals(a)) {
system.out.println(“Two strings are equal”);
} else {
system.out.println(“Two strings are not equal”);
}
}
}
CorrectIncorrect -
Question 3 of 15
3. Question
Which of the following is the right syntax for a nested if loop ?
CorrectIncorrect -
Question 4 of 15
4. Question
class Sample {
public static void main ( String args [ ] )
{
int a = 4 ;
if( a < 10 ) {
if ( a < 5 ) {
system.out.println(“The number is also less than 5 “);
}else {
system.out.println(“The number is less than 10 alone “);
}
CorrectIncorrect -
Question 5 of 15
5. Question
If the input value from the user does not match with any case statements in the switch case , which block of statement will be executed ?
CorrectIncorrect -
Question 6 of 15
6. Question
class SwitchExample {
public static void main ( String args [ ] )
{
int a = 5 ;
switch(a)
{
case 5:
{
system.out.println(“Number is 5 “);
}
case 6:
{
system.out.println(“Number is not a 5 “);
}
Default:
{
system.out.println(“It is an unknown number”);
}
}
}
}
CorrectIncorrect -
Question 7 of 15
7. Question
class Demo {
public static void main ( String args [ ] )
{
int x = 0;
switch(x)
{
case 0 :
{
system.out.println(“The number is 0 “);
break;
}
case 1:
{
system.out.println(“The number is not zero “);
break;
}
}
}
}
CorrectIncorrect -
Question 8 of 15
8. Question
Which of the following is true about the switch case ?
CorrectIncorrect -
Question 9 of 15
9. Question
class SwitchCaseSample {
public static void main ( String args [ ] )
{
float pi = 3.14;
switch(pi)
{
case 3.14:
{
system.out.println(“This is the value of PI “);
break;
}
default:
{
system.out.println(“This is not the value of PI”);
break;
}
}
}
}
CorrectIncorrect -
Question 10 of 15
10. Question
Which of the following is the correct syntax of a switch case in Java ?
CorrectIncorrect -
Question 11 of 15
11. Question
class ReturnStatement {
public static void main ( String args [ ] )
{
int a = 10;
if(a == 10) {
system.out.println(a);
return;
++a;
system.out.println(a);
}
}
}
CorrectIncorrect -
Question 12 of 15
12. Question
class ContinueStatement {
public static void main( String args [ ] ) {
int [ ] marks = {88 , 89 , 29 , 91 , 92};
for(int x : marks ) {
if( x <= 35 ) {
continue;
}
system.out.println(“Subjects passed are :”);
System.out.print( x );
}
}
}
CorrectIncorrect -
Question 13 of 15
13. Question
When there will be a compile time error in the if statement?
CorrectIncorrect -
Question 14 of 15
14. Question
class NestedIf {
public static void main ( String args [ ] )
{
int a = 8;
if(a<10) {
if(a<=8) {
if(a<8){
system.out.println(“ Number is less than 8 “);
}
system.out.println(“Number is less than or equal to 8”);
}
system.out.println(“Number is greater than 10);
}
}
}
CorrectIncorrect -
Question 15 of 15
15. Question
Which of the following statements is more efficient than executing a long if else ladder?
CorrectIncorrect
Summary:
This interactive quiz has put those skills to the test, covering a range of decision-making concepts. By taking this quiz, you’ve actively engaged with different problem-solving scenarios, reinforcing your knowledge and identifying areas for further exploration.
Remember, continuous practice and exploration are key to mastering any programming language. Keep exploring, keep practising, and make those decisions count in your Java code!
