Test : Java_19
This test contains 10 questions based on Java.
Each question answered correctly awards you 1 point and each incorrect answer has a penalty of -0.25 points, no points are deducted for unattempted answers.
Each question answered correctly awards you 1 point and each incorrect answer has a penalty of -0.25 points, no points are deducted for unattempted answers.
Select Test Type
You Get +1 for each correct answer and -0.25 for each incorrect answer
Time Left - minutes :seconds
Which of these packages contains abstract keyword?
| java.util | java.io |
| java.system | java.lang |
D
A subclass of an abstract class can also be abstract if
| It is instantiated | The static class is declared in the parent class |
| It does not define all the abstract methods in the parent class | All of the above |
C
What is the name of the class that is the ancestor to every other class in Java?
| Object | Class |
| root | java |
A
In Java by default all the classes extend Object class directly or indirectly. A class declaration without the extends clause, implicitly extends the object class.
Which of the following is a method having same name as that of its class?
| finalize | delete |
| class | constructor |
D
A constructor is a method that initializes an object immediately upon creation. It has the same name as that of class in which it resides
Which of these keywords is used to define interfaces in Java?
| interface | Interface |
| intf | Intf |
A
What is the output of this program?
import java.io.*;
class Chararrayinput {
public static void main(String[] args) {
String obj = "abcdefgh";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0, length, c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 1, 4);
int i;
int j;
try {
while((i = input1.read()) == (j = input2.read())) {
System.out.print((char)i);
}
}
catch (IOException e) {
e.printStackTrace();
}
}
}| abc | abcd |
| abcde | None of the above |
D
Which of these packages contain all the collection classes?
| java.lang | java.util |
| java.net | java.awt |
B
What is the output of the following code:
abstract class Shape
{
void display()
{
}
}
class Circle extends Shape
{
void display()
{
System.out.println("You are using circle class");
}
}
class Rectangle extends Shape
{
void display()
{
System.out.println("You are using rectangle class");
}
}
class Triangle extends Shape
{
void display()
{
System.out.println("You are using triangle class");
}
}
class AbstractClassDemo
{
public static void main(String args[])
{
Shape sObj = new Circle();
sobj.display();
sObj = new Rectangle();
sobj.display();
sObj = new Triangle();
sobj.display();
}
}| You are using triangle class You are using rectangle class You are using circle class | You are using rectangle class You are using circle class You are using triangle class |
| You are using circle class You are using triangle class You are using rectangle class | You are using circle class You are using rectangle class You are using triangle class |
D
String in Java is a?
| class | object |
| variable | character array |
A
Which of these access specifiers must be used for main() method?
| private | public |
| protected | None of the mentioned |
B
main() method must be specified public as it called by Java run time system, outside of the program. If no access specifier is used then by default member is public within its own package & cannot be accessed by Java run time system.
Finish Test
Test : Java_19
Reviewed by Ekansh Rastogi
on
19:37
Rating: 5