NEW
Font size
WorksheetsJava Practice Test
Total questions: 26
Worksheet time: 15mins
Find the output of the following code.
int Integer = 24;
char String = ‘I’;
System.out.print(Integer);
System.out.print(String);
I
24
Compile time error
24 I
Find the output of the following program.
public class Solution{
public static void main(String[] args){
short x = 10;
x = x * 5;
System.out.print(x);
}
}
50
10
Exception
Compile time error
Find the output of the following program.
public class Solution{
public static void main(String[] args){
byte x = 127;
x++;
x++;
System.out.print(x);
} }
129
128
-127
2
Select the valid statement.
char[] ch = new char(5)
char[] ch = new char[5]
char[] ch = new char()
char[] ch = new char[]
Select the valid statement to declare and initialize an array.
int[] A = {}
int[] A = {1, 2, 3}
int[] A = (1, 2, 3)
int[][] A = {1,2,3}
Arrays in java are-
Object references
objects
Primitive data type
None
When is the object created with new keyword?
At run time
At compile time
Depends on the code
None
Identify the corrected definition of a package.
A package is a collection of editing tools
A package is a collection of classes
A package is a collection of classes and interfaces
A package is a collection of interfaces
Identify the correct restriction on static methods.
They must access only static data
They can only call other static methods.
They cannot refer to this or super.
I and II
II and III
Only III
I, II and III
Identify the keyword among the following that makes a variable belong to a class, rather than being defined for each instance of the class.
final
static
volatile
abstract
Identify the output of the following program.
Public class Test{
Public static void main(String argos[]){
String str1 = “one”;
String str2 = “two”;
System.out.println(str1.concat(str2));
} }
one
two
onetwo
twoone
Java was developed by Dennis Richie.
Yes
No
Who invented Java Programming?
Guido van Rossum
James Gosling
Dennis Ritchie
Bjarne Stroustrup
Which statement is true about Java?
Java is a sequence-dependent programming language
Java is a code dependent programming
Java is a platform-dependent programming language
Java is a platform-independent programming language
Tell me name of 6th part of Harry Potter.
Harry Potter and the Philosopher's Stone
Harry Potter and the Goblet of Fire
Harry Potter and the Half-Blood Prince
Harry Potter and the Chamber of Secrets
Look at this series: 12, 11, 13, 12, 14, 13, … What number should come next?
10
16
13
15
Which of the following is not a Java features?
Dynamic
Architecture Neutral
Use of pointers
Object-oriented
Look at this series: 2, 1, (1/2), (1/4), … What number should come next?
(1/3)
(1/8)
(2/8)
(1/16)
Which word does NOT belong with the others?
index
glossary
chapter
book
An interface with no fields or methods is known as a ______.
Runnable Interface
Marker Interface
Abstract Interface
CharSequence Interface
Which of these classes are the direct subclasses of the Throwable class?
RuntimeException and Error class
Exception and VirtualMachineError class
Error and Exception class
IOException and VirtualMachineError class
What do you mean by chained exceptions in Java?
Exceptions occurred by the VirtualMachineError
An exception caused by other exceptions
Exceptions occur in chains with discarding the debugging information
None of the above
Which keyword is used for accessing the features of a package?
package
import
extends
export
Multiple Inheritance is supported in java by "extends" keyword.
Yes
No
Which of the following is a mutable class in java?
java.lang.String
java.lang.Byte
java.lang.Short
java.lang.StringBuilder
Have you enjoyed??
Yes
No
Not Sure
