WorksheetsComprog - (Review) - October 24, 2022
Total questions: 25
Worksheet time: 13mins
Which of the following is a LEGAL identifier?
2ndScore
First-number
_ratePerHour
main
Which of the following statement is a CORRECT?
System.out.println("Hello);
System.out.println("Hello");
System.out.println("Hello")
System.out.println(Hello);
Which of the following statement is NOT true?
Every Java program starts from a main method
In Java, OK and ok are the same
/* */ indicates a comment line
static is a reserved word
Who is the father of Java?
James A. Gosling
Jeffrey A. Gosling
Jerry A. Gosling
Joseph A. Gosling
Which of the following is NOT a Java data type?
String
void
boolean
static
Which of the following is the equivalent compound statement, x = x / 5;?
x /= 5;
x // 5;
x =/ 5;
xx / 5;
Which of the following is a correct variable declaration?
int x, y = 23;
double p = 10%;
String message = hello;
char choice = “Y”;
What is the output of the statement,
System.out.print(25 >= 15);
25
true
false
15
Which of the following statement is INCORRECT?
Integer.parseInt(output);
Double.parseDouble(output);
Float.parseFloat(output);
String.parseString(output);
Which of the following does NOT belong to the group?
JOptionPane.INFO_MESSAGE;
JOptionPane.ERROR_MESSAGE;
JOptionPane.QUESTION_MESSAGE;
JOptionPane.PLAIN_MESSAGE;
What is the result of the logical expression,
(true || true) && false ?
true
false
What is the output of the statement,
System.out.print((double)(2 + 6 * 3)) ?
20.0
20
24
24.0
Which of the following is a relational operator?
||
<>
=
!=
Identify the output of the following code:
int grade = 90;
if(grade == 90)
System.out.print(“great”);
System.out.print(“ job”);
great
job
great job
greatjob
Identify the output of the following code:
String section = “Divine”;
int grade = 11;
System.out.printf(“%d - %s”, grade, section);
11 - Divine
Grade 11 Divine
Grade 11 - Divine
Grade Divine - 11
Identify the output of the following code:
int number = 14;
if(number %2 == 0)
System.out.print(“Even”);
else
System.out.print(“Odd”);
Even
Odd
Even
Odd
EvenOdd
Identify the output of the following code:
double rate = 40.0;
if(rate > 50.0)
System.out.println(rate * 2);
else if(rate > 40.0)
System.out.println(rate / 2);
else
System.out.println(rate – 2);
80.0
20.0
38.0
42.0
Which of the following statements produces error?
char c = (a > b) ? 10: 15;
int x = (a % 2==0) ? 2 : 4;
String y = (a == “Apple”) ? “fruit”: “vegetable”;
char res = (a != b) ? ‘A’ : ‘B’;
Identify the output of the following code:
int score = 5;
char gender = ‘F’;
if(score > 10 || gender == ‘M’)
System.out.print(“Good”);
if(score > 10 || gender == ‘F’)
System.out.print(“Great”);
Good
Great
GoodGreat
No output
Identify the output of the following code:
int num1 = 30, num2 = 10;
int min = (num1 < num2) ? 30 : 10;
System.out.println(min);
10
30
1030
No output
Which of the following is a logical operator?
!!
!
!=
<>
Which is the alternative to switch in Java language?
break, continue
if, else
do-while
goto, exit
A switch statement accepts ___ type of data as input.
byte
int
long
all of the choices
Identify the output of the following code:
int numFruits = 37;
int choice = 37;
switch(choice) {
case numFruits: System.out.print("MANGO");
break;
default: System.out.println("APPLE");
}
APPLE
MANGO
MANGOAPPLE
APPLEMANGO
Which of the following is INCORRECT?
import java.util.Scanner;
import javax.swing;
import java.io.FileReader;
import java.io.PrintWriter;
