WorksheetsJava Programming Quiz
Total questions: 20
Worksheet time: 13mins
What is the default package in Java?
java.default
java.package
The unnamed package
java.lang
What is the default value of a boolean variable in Java?
True
False
0
Null
What will be the output of the following Java code? { int g = 3; System.out.println(++g * 8); }
24
32
25
33
Which keyword is used to declare a constant variable in Java?
Const
Final
Static
None
In Java, System.out.println(11/4); output is
2.5
2
2.0
3
What is the correct syntax to read input from the user?
Scanner sc = new Scanner(System.in);
System.read();
input sc = new Scanner();
None
System.out.println("Hello\nWorld"); what will be the Output:_____________
Hello\nWorld
HelloWorld
Hello World
Compilation error
Return type _________ indicates that a method will not return a value.
Int
Void
Float
None
Which of the following is a method having same name as that of it’s class?
Object
Class
Constructor
Void
int x = 5; System.out.println(++x + ++x);
11
12
13
None
Which keyword refers to the current object?
Super
Object
This
None
The keyword used to prevent inheritance of a class is:
Abstract
Final
Static
Const
________________allows the same method name but different parameters?
Overriding
Encapsulation
Abstraction
Overloading
Find the output of the following code. int Integer = 24; char String = ‘I’; System.out.print(Integer); System.out.print(String);
Throws Exception
Compile Error
Id
24 I
int a = 10, b = 20; System.out.println(a > b ? a : b);
10
20
30
None
The output of the Java compiler is known as (a) .
The process of converting one data type into another is called (a) .
A class is a blueprint for creating (a) .
The process of binding variables and methods is called (a) .
class Test { protected float x, y; } class Demo { public static void main(String args[]) { Test t = new Test(); System.out.println(t.x + " " + t.y); } } Output: ____________________________________________________
