Java MCQ Questions and Answers on Relational Operators 1

Study and learn Java MCQ questions and answers on Relational Operators or Comparison Operators. Also, learn their priorities. Attend job interviews easily with these Multiple Choice Questions.

Go through Java Theory Notes on Relational Operators before studying questions.



1) What is the other name for Relational Operators in Java?
A) Comparison operators
B) Conditional operators
C) A and B
D) None of the above
Answer [=]
Answer[=]
2) How many minimum number of operands are required to use Comparison operators in Java?
A) 1
B) 2
C) 3
D) 4
Answer [=]
Answer[=]
3) What are the types of data that can be used along with Relational operators in Java?
A) char, boolean, Object
B) byte, short, int, long
C) float, double
D) All the above
Answer [=]
Answer[=]
4) Choose the Conditional operators of Java listed below.
A) >, >=
B) <, <=
C) ==, !=
D) All the above
Answer [=]
Answer[=]
5) Which operator group has higher priority between (>, >=, <, <=) and (==, !=)?
A) (>, >=, <, <=) has lower priority (==, !=)
B) (>, >=, <, <=) has higher priority (==, !=)
C) (>, >=, <, <=) has equal priority with (==, !=)
D) None of the above
Answer [=]
Answer[=]
6) What is the output of the Java code snippet?
int k=20;
if(k)
{
  System.out.println("YES");
}
else
{
  System.out.println("NO");
}
A) NO
B) YES
C) Compiler error
D) None of the above
Answer [=]
Answer[=]
7) What is the output of Java code snippet?
int[] ary = {5,6,7,8};
if(ary.length > 2)
{
  System.out.println(ary[2]);
}
A) 6
B) 7
C) 8
D) Compiler error
Answer [=]
Answer[=]


 

8) What is the data type of output of any Comparison Operation in Java?
A) int
B) char
C) boolean
D) byte
Answer [=]
Answer[=]
9) What is the output of the Java code snippet?
char ch='A';
if(ch > 70)
{
  System.out.println("PIZZA");
}
else
{
  System.out.println("BURGER");
}
A) PIZZA
B) BURGER
C) Compiler error
D) None of the above
Answer [=]
Answer[=]
10) What is the output of Java code snippet?
int a=5, b=10;
if(++b>10||a++=5)
{
  System.out.println("PIZZA="+a);
}
else
{
  System.out.println("BURGER="+a);
}
A) PIZZA=5
B) PIZZA=6
C) BURGER=5
D) BURGER=6
Answer [=]
Answer[=]
11) Among Relational operators and Assignment operators, which operators have higher priority?
A) Assignment operators have lower priority than Relational operators
B) Assignment operators have higher priority than Relational operators
C) Assignment operators have equal priority with Relational operators
D) None of the above
Answer [=]
Answer[=]
12) What is the output of the Java code snippet?
int a=20, b=10;
boolean c = a>=10 & b<20;
System.out.println(c);
A) false
B) true
C) Compiler error
D) None of the above
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.