<span class="greencolor2">Enrol for Java Certification</span>
Certifications Boost Confidence. Go through Certifications CENTER
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.
//Two operators one on the left //one on the right. if(a <= b) { }
int k=20; if(k) { System.out.println("YES"); } else { System.out.println("NO"); }
Error: if(k) --> k is not boolean
Type mismatch: cannot convert from int to boolean
int[] ary = {5,6,7,8}; if(ary.length > 2) { System.out.println(ary[2]); }
All Java arrays have a "length" field which holds the size of that array.
char ch='A'; if(ch > 70) { System.out.println("PIZZA"); } else { System.out.println("BURGER"); }
ASCII or UNICODE value of character 'A' is 65. A char value is converted to int before comparing it.
int a=5, b=10; if(++b>10||a++=5) { System.out.println("PIZZA="+a); } else { System.out.println("BURGER="+a); }
If Short Circuit OR (||) does not evaluate a++==5 as the first expression is true. So a is still 5.
int a=20, b=10; boolean c = a>=10 & b<20; System.out.println(c);
Open Certification Helper Popup Reset Popup