Java IF ELSE IF Control Statements Interview MCQ Questions and Answers

Study and learn Interview MCQ Questions and Answers on Java IF ELSE IF Control Statements. Attend job interviews easily with these Multiple Choice Questions. You can print these Questions in default mode to conduct exams directly. You can download these MCQs in PDF format by Choosing Print Option first and Save as PDF option next using any Web Browser.

Go through Java Theory Notes on IF ELSE Control Statements before reading these objective questions.



1) An IF-ELSE statement is also called ___.
A) Branching statement
B) Control statement
C) Block statements
D) All
Answer [=]
Answer[=]
2) An IF or ELSE IF statement accepts ___ as input before branching.
A) boolean
B) int
C) float
D) char
Answer [=]
Answer[=]
3) An IF statement in Java is also a ___ statement.
A) boolean
B) conditional
C) iterative
D) optional
Answer [=]
Answer[=]
4) Java style IF-ELSE statements are similar to ___.
A) C style
B) C++ Style
C) Both C and C++ style
D) None
Answer [=]
Answer[=]
5) State TRUE or FALSE. Every IF statement must be followed by an ELSE of ELSE-IF statement.
A) TRUE
B) FALSE
C) -
D) -
Answer [=]
Answer[=]
6) An ELSE statement must be preceded by ___ statement in Java.
A) IF
B) ELSE IF
C) IF or ELSE IF
D) None
Answer [=]
Answer[=]
7) State TRUE or FALSE. A Single-Line comment or Multiline-comment is allowed in between if () and Left Brace ( { ).
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]


 

8) State TRUE or FALSE. An IF statement code must be defined in between two Braces.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
9) State TRUE of FALSE. The code inside an ELSE statement may be surrounded by Braces.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
10) State TRUE or FALSE. An ELSE or ELSE-IF statement in Java can not exist alone without IF statement.
A) FALSE
B) TRUE
C) -
D) -
Answer [=]
Answer[=]
11) The condition of an IF statement evaluates to boolean only if the expression contains?
A) logical operators
B) relational operators
C) boolean operands
D) All
Answer [=]
Answer[=]
12) If the condition of an IF-statement is false, which is true below.
A) IF block is executed.
B) ELSE block is executed.
C) Both IF and ELSE blocks are skipped.
D) Both IF and ELSE blocks are executed.
Answer [=]
Answer[=]
13) What is maximum lines of code that can be written inside a Java style IF, ELSE or IF-ELSE block?
A) 32
B) 64
C) 512
D) None
Answer [=]
Answer[=]
14) An IF-ELSE statement is better than a SWITCH statement in which scenario below?
A) Checking for More-than condition
B) Checking for Less-than condition
C) Checking for Ranges
D) All
Answer [=]
Answer[=]


 

15) What is the maximum number of ELSE-IF statements that can present in between starting IF and ending ELSE statements?
A) 32
B) 64
C) 128
D) None
Answer [=]
Answer[=]
16) Choose the correct syntax of Java IF statement below.
A)
if(condition)
  //statement
B)
if(condition)
{
  //statement
}
C)
if(condition)
{
  //statement1
  //statement2
}
D) All
Answer [=]
Answer[=]
17) Choose a wrong statement on Java IF-ELSE syntax below.
A)
if(condition)
  //statement1
else
  //statement2
B)
else
  //statement2
C)
if(condition1)
  //statement1
else if(condition2)
  //statement2
D)
if(condition1)
  //statement1
else if(condition2)
  //statement2
else
  //statement3
Answer [=]
Answer[=]
18)
What is the output of Java program with IF statement?
if(1)
{
  System.out.println("OK");
}
A) OK
B) No output
C) Compiler error
D) None
Answer [=]
Answer[=]
19) What is the output of the Java program with IF-ELSE statements?
if(TRUE)
  System.out.println("GO");
else
  System.out.println("STOP");
A) GO
B) STOP
C) Compiler error
D) None
Answer [=]
Answer[=]
20) What is the output of the Java program?
int a=10;
if(a==9)
  System.out.println("OK ");
  System.out.println("MASTER");					
else
  System.out.println("BYE");
A) OK MASTER
B) BYE
C) Compiler error
D) None
Answer [=]
Answer[=]
21) What is the output of the Java program?
String name1="FOX", name2="DOG";
if(name1 == "FOX")
  System.out.print("FOX ");
  System.out.println("GOOD");					
if(name2 == "CAT")
  System.out.println("DINO");
A) FOX DINO
B) FOX GOOD DINO
C) Compiler error
D) None
Answer [=]
Answer[=]


 

22) What is the output of the Java program?
String name="dino";
if(name == "dino")
	System.out.print("DINO");
System.out.println("GOOD");	
A) DINO GOOD
B) DINO
C) GOOD
D) Compiler error
Answer [=]
Answer[=]
23) What is the output of the Java program with IF-ELSE-IF statements?
int marks=55;
if(marks >= 80)
  System.out.println("DISTINCTION");
else if(marks >=35)
  System.out.println("PASS");
else
  System.out.println("FAIL");
A) DISTINCTION
B) PASS
C) FAIL
D) Compiler error
Answer [=]
Answer[=]
24) What is is the output of the Java program?
int marks=85;
if(marks >= 80)
  System.out.println("DISTINCTION");
else if(marks >=35)
  System.out.println("PASS");
A) DISTINCTION
B) PASS
C) Compiler error
D) None
Answer [=]
Answer[=]
25) What is the output of Java program below?
float temp = 98.4f;
if(temp > 98.4)
{
  System.out.println("SUMMER");
}
else
{
  System.out.println("UNKNOWN");
}
A) SUMMER
B) UNKNOWN
C) Compiler error
D) None
Answer [=]
Answer[=]
26) What is the output of the Java program?
long num = 123L;
if(num > 123)
{
	System.out.println("TIGER");
}
else
{
	System.out.println("BIRD");
}
A) TIGER
B) BIRD
C) Compiler error
D) None
Answer [=]
Answer[=]
27) What is the output of the Java program?
int horses = 10;
int camels = 5;
if(horses > 5)
{
  if(camels > 3)
  {
    System.out.println("FOREST");
  }
}
else
{
   System.out.println("CITY");
}
A) FOREST
B) CITY
C) Compiler error
D) None
Answer [=]
Answer[=]
28) What is the output of the Java program?
int horses = 10;
int camels = 5;
if(horses < 5)
{
  System.out.println("TOWN");
}
else if(horses >=5)
  System.out.print("FOREST ");
  System.out.println("AMAZON");
else
  System.out.println("UNKNOWN");
A) TOWN
B) FOREST AMAZON
C) UNKNOWN
D) Compiler error
Answer [=]
Answer[=]
29) What is the output of the Java program?
int marks=29;
if(marks > 29);
   System.out.print("PASS ");
System.out.println("RANK");	
A) RANK
B) PASS
C) PASS RANK
D) Compiler error
Answer [=]
Answer[=]
30) What is the output of the Java program below?
if(3>1)
{
  4;
}
A) 0
B) 4
C) Compiler error
D) None
Answer [=]
Answer[=]
31) What is the output of the Java program with IF statement?
if(true)
{
   break;
   System.out.println("ELEPHANT");
}
A) No output
B) ELEPHANT
C) Compiler error
D) None
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Try Some Java Books

Book Price
1. Java - The Complete Reference  Check Price
2. Core Java: An Integrated Approach, Black Book Check Price
3. Java All-in-One for Dummies Check Price
4. OCP Java SE 8: Programmer II Check Price
5. Programming with Java Check Price
6. Head First Java Check Price

We may get some affiliate commission for the above purchases.