WorksheetsEPA-11-DEC-2021 On Java
Total questions: 50
Worksheet time: 56mins
Which of these can not be used for a variable name in Java?
identifier
identifier & keyword
keyword
none of the mentioned
Which of the following is not an operator in Java?
instanceof
sizeof
>>>=
new
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
while
do-while
for
none of the mentioned
What is the output of relational operators?
Integer
Boolean
Characters
Double
Which component is used to compile, debug and execute java program?
jre
jvm
jdk
jit
What is the stored in the object obj in following lines of Java code?
Box b;
here Box is a class
Memory address of allocated memory of object
NULL
Any arbitrary pointer
Garbage
Which of the following is not a Java features?
Dynamic
Architectural Neutral
Pointer
static
_____ is used to find and fix bugs in the Java programs.
JVM
JRE
JDB
JDK
What does the expression float a = 35 / 0 return?
0
NOT A NUMBER
INFINITY
RUN TIME EXCEPTION
Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?
delete
free
new
none of the mentioned
Which of the following option leads to the portability and security of Java?
Bytecode is executed by JVM
The applet makes the Java code secure and portable
Use of exception handling
Dynamic binding between objects
What is the advantage of Exception Handling
To avoid abnormal termination of a program
To find out errors
To Debug program
None of these
What is the purpose of 'throw' keyword
To Raise an exception explicityly
To Raise an exception implicityly
To create user defined exceptions
To create custom exceptions
What is an exception
Error occurred during the execution of a program
Bug occurred during the compile time of a program
Simply an Error
It is related to input values
Exception classes belongs to following package
import java.io.*
import java.lang.*
import java.util.*
import java.lang.Exception.*
Choose the CORRECT exception
String department="JTMK";
Integer no=Integer.parseInt(department);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundsException
Choose an exception if attempt to divide number by zero
int number = 89 / 0;
System.out.println("The answer is " + number);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundException
1. Which of these keywords must be used to monitor for exceptions?
a) try
b) finally
c) throw
d) catch
2. Class at the top of exception class hierarchy?
ArithmeticException
Throwable
Object
Exception
Which of the below is/are valid identifier with the main method?
public
private
static
this
For the array:
int stats[3];
What is the range of the index?
0 to 3
0 to 2
1 to 3
0 to 4
Is String a primitive data type?
Yes
No
Both
Which of the following variable is declared as static?
Home address of a particular Student
Account number of a Customer
Company name of all Employees in an Organization
Name of a Employee
Which of the following is not a correct statement?
A class can have any number of static blocks
Static method is accessed directly using class name
Separate memory is allocated for each object for all static variables
Static method is executed before main() method once a class is loaded
Which of the following is Mutable object
String
StringBuffer
After a StringBuffer has been constructed, how many characters may be added to it?
No more after it has been constructed.
Only as many as the original capacity.
As many as needed; it will grow in size if necessary.
A new StringBuffer must be constructed each time characters are added.
What is the potential number of characters in a StringBuffer called?
length
size
width
capacity
what will be output of below program
Compile Time error
0 0
Run time Exception
No Output
What will be output of follwoing program
Base
Derived
Derived
Derived
Derived
Base
Derived
Base
Derived
compile time error
what will be output of follwing program
Compile time error
Run time Exception
x= 0 y=0
x= 1 y= 1
what will be output of following program?
400
200
10
10
400
200
200
400
10
10
200
400
what will be output of following program?
20
10
2
20
what will be output of following program?
The output is true and LNCT fulfills the Object.equals() contract.
The output is false and LNCT fulfills the Object.equals() contract.
The output is true and LNCT does NOT fulfill the Object.equals() contract.
The output is false and LNCT does NOT fulfill the Object.equals() contract.
You wish to compare the contents of two StringBuffer objects. How should this be done?
Use the == operator.
Use the equals() method of StringBuffer.
Construct a String object from each StringBuffer and use their equals() method.
Do a character-by-character comparison using charAt() and ==.
Choose the correct statement about the given code:
The code will not compile because of line 2.
The code will not compile because of line 4.
The code will not compile because of line 7.
It compiles but throws an exception at runtime.
Choose the correct statement about the given code:
The code will not compile because of line 3.
The code will not compile because of line 4.
The code will not compile because of lines 3 and 4.
It compiles and runs without issue.
Choose the correct statement about the given code:
It compiles without issue.
The code will not compile because of line 2.
The code will not compile because of line 4.
The code will not compile because of lines 2 and 5.
Which statements are true about the given code? (Choose all that apply)
The CanBark interface doesn’t compile.
A class that implements CanBark inherits both the makeSound() and bark() methods.
A class that implements CanBark only inherits the bark() method.
An interface cannot extend another interface.
What is the output of the given code?
Lizard laying eggs
The code will not compile because of line 4.
The code will not compile because of line 2.
The code will not compile because of line 9.
What is the result of the given code?
Bird is flying
Pelican is flying
The code will not compile because of line 4.
The code will not compile because of line 9.
What is the result of compiling and executing the following class?
It does not compile.
It compiles but throws an exception at runtime.
It compiles and outputs 5.
It compiles and outputs 15.
Which statement about the given code is correct?
The code does not compile due to line g1.
The code does not compile due to line g2.
The code does not compile due to line g3.
The code compiles and runs without issue.
What will it print?
1
2
3
30
1
2
30
1
2
3
11
1
2
11
