TOTAL QS = 24Time [ 00 : 00 : 00 ]
00:00:00

Java Basics: Ternary Operator Online Test 1

Instructions

Total Questions: 24

Total Minutes: 24

This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on Java Ternary Operator or Conditional Operator. This test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics.

Go through Java Theory Notes on Ternary Operator before attempting this test.

All the Best

Challenge SCORE

0 / 24

Take This Exam
1) What is the other name for a Question Mark - Colon (?:) operator in Java?
2) Java Ternary operator is sometimes called ____.
3) The condition of a Java Ternary operator should evaluate to ___.
4) State TRUE or FALSE. True expression part comes first after ? (question mark) symbol and before : (colon) symbol.
5) Java Ternary operator can be used with ___.
6) A java Ternary operator has priority less than ___.
7) Java assignment operator has priority more than ___.
8) The True Part Expression of a Java conditional operator or Ternary operator ____ return a value.
9) The False Part Expression of a Java conditional operator or Ternary operator ____ return a value.
10) Choose a possible error with a Ternary operator while compiling a Java program.
11) You can nest one Java Ternary operator inside another Ternary operator. State TRUE or FALSE.
12) What is the output of the code snippet with the ternary operator?
int p=5;
System.out.print("Hello ");
(p<6)?5:6;
13) What is the output of the Java code snippet with Ternary operator?
int num = false?10:20;
System.out.println(num);
14) What is the output of the Java code snippet with Ternary operator?
String name = "java";
int marks = name == "java"?10:20;
System.out.println("Marks=" + marks);
15) What is the output of the Java code snippet with a Ternary operator?
String name = "cat";
int marks = name == "Cat"?10:20;
System.out.println("Marks=" + marks);
16) What is the output of the Java code snippet with a Ternary operator?
String name1 = "pen";
String name2 = "pen";
int marks = name2.equals(name1)?50:80;
System.out.println("Marks=" + marks);
17) What is the output of the Java code snippet with a Ternary operator?
void show()
{
  int num = true ? getNumber() : 20;
  System.out.print("TOMATO=" + num);
}
	
void getNumber()
{
  System.out.print(30);
}
18) What is the output of Java code snippet with a Ternary operator or Conditional operator?
void show()
{
  String name = true ? getName() : "FRANCE";
  System.out.print(name);
}

void getName()
{
  System.out.print("ENGLAND");
}
19) What is the output of Java code snippet with a Ternary operator?
String forest = null;
String output = forest != null ? "Goblin" : "Amazon";
System.out.println(output);
20) What is the output of the Java code snippet below?
int a = 20, b=30;
int total = a>10&&b<10?65:75;
System.out.println(total);
21) What is the output of the Java code snippet below?
int a = 20, b=30;
boolean result = a&b?true:false;
System.out.println(result);
22) What is the output of the Java code snippet below?
int a = 4, b=7;
int result = (true?a&b:a|b)>3?120:150;
System.out.println(result);
23) What is the output of Java code snippet below?
final int a = 25, b=33;
String name = !true?"Dino":"Tom";
System.out.println(name);
24) What is the output of Java code snippet below?
int a = 25, b=33;
String name = true?"CAT":;
System.out.println(name);
Certification Group ID
3845

Open Certification Helper Popup Reset Popup