Font size
WorksheetsJava Programming Quiz
Total questions: 15
Worksheet time: 9mins
Which component is responsible to optimize reusable byte code conversion to machine code?
Class Loader
Interpreter
JIT Compiler
Byte Code Verifier
Predict the output: public static void main(String args[]) { int age; System.out.println(age); }
0
garbage value
compilation error : variable needs to be initialized before use
2147483647
Which of these values can a boolean variable contain?
true
false
0
1
identifiers cannot start with __________
character
digit
_
$
Predict the output: public class Demo{ public static void main (string args[]){ int a =10,b=9; System.out.println(a
true
false
10
9
public static void main(String args[]){ int i=10; if(i) System.out.println("Hello"); else System.out.println("Bye"); }
Hello
Compilation error: incompatible types: int cannot be converted to boolean
Bye
runtime error
If an arithmetic expression contains variables of int , byte , and short data types , what will be the data type of its result?
int
byte
float
short
public static void main(String[] args){ int num1 = 20; double num2 = 0; if(num1 >= 20) num2=1.5; if(num1<30) num2 = 2; System.out.println("Value of num2 is "+ num2); }
Value of num2 is 2
Value of num2 is 1.5
Value of num2 is 2.0
Value of num2 is 1.50
Can we compare int variable with a Boolean variable?
True
False
What is the output of the below Java code snippet?
char ch = 'A';//ASCII 65
int a = ch + 1;
ch = (char)a;
System.out.println(ch);
A) 66
B) A
C) B
D) 65
Which of the following is a comment in the Java language?
/ comment /
/* comment */
/ comment */
<-- comment -->
Which of the following is the correct main() method signature in Java?
public static void main (String [] args)
public static void Main (String [] args)
public static void main (string [] args)
public static void main (String args)
The import statement used in Java to access the Scanner class is:
import java.Scanner;
import java.util.Scanner;
import java.package.Scanner
import.java.util.Scanner;
What is a class in object-oriented programming?
A class is a template with data and methods
A class is a package
A class is the declared object in memory
A class is a reference object in memory
Which of the following is a reserved word in Java?
export
import
input
output
