No student devices needed. Know more
39 questions
Which of this keyword must be used to inherit a class?
super
this
extent
extends
A class member declared protected becomes a member of subclass of which type?
public member
private member
protected member
static member
Which of these is correct way of inheriting class A by class B?
class B + class A {}
class B inherits class A {}
class B extends A {}
class B extends class A {}
What is the output of this program?
0
1
2
Compilation Error
What is the output of this program?
2 2
3 3
2 3
3 2
What is the output of this program?
1 2
2 1
Runtime Error
Compilation Error
What is not type of inheritance?
Single inheritance
Double inheritance
Hierarchical inheritance
Multiple inheritance
what is the output?
Base
Derived
compile time error
run-time error
Output of following Java program?
Base
Derived
Derived
Base
Base
Derived
Base
Derived
Base
Compiler Error
Which of the following is true about inheritance in Java?
1, 2 and 4
Only 1 and 2
1, 2 and 3
2, 3 and 4
output of the program
Base::show() called
Compiler Error
Derived::show() called
None
output of the program
Base::show() called
Derived::show() called
Compiler Error
Runtime Error
Output of following Java Program?
Derived::show() called
compile time error
Base::show() called
runtime error
Predict the output of following Java program?
0
garbage value
compile time error
runtime error
Predict the output of following Java program
garbage value
0
compile time error
runtime error
output of the program
Compile error
values of obj1:
a = 11 b = 21
values of obj2:
a = 11 b = 21
values of obj1:
a = 11 b = 21
values of obj2:
a = 10 b = 20
values of obj1:
a = 11 b = 20
values of obj2:
a = 10 b = 21
runtime error
Predict the output of the following program.
Compilation error
Inside First
Inside First
Inside First
Inside Second
Runtime error
What is the output of the following JAVA program ?
dogood : dogoodgood
dogood : gooddogood
dogood : dodogood
dogood : dogood
Predict the output?
20
0
Compiler Error
none
Which of the following is/are true about constructors in Java?
1
1,2
1, 2, 4
1,2,3 & 4
output of the program
inside static block
a = 4
inside constructor
a = 11
Compiler Error
Run Time Error
inside static block
a = 4
inside constructor
a = 5
inside static block
a = 10
inside constructor
a = 11
What is the process of defining a method in a subclass having same name & type signature as a method in its superclass?
Method overloading
Method overriding
Method hiding
None of the mentioned
What is the output of this program?
2
3
7
compile time error
what is the output
9.0 9.0
9 9
compile time error
none
I am a Person
I am a Student
I am a Person I am a Student
I am a Student I am a Person
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?
Public
Protected
No Modifier
All of the mentioned
Which of these access specifiers can be used for a class so that its members can be accessed by a different class in the different package?
Public
Protected
Private
No Modifier
Which of the following is an incorrect statement about packages?
Package defines a namespace in which classes are stored
A package can contain other package within it
Java uses file system directories to store packages
A package can be renamed without renaming the directory in which the classes are stored
For which purpose packages are used in Java?
Categorizes data
Organizing java classes into namespaces
faster compilation
None of These
A package is a collection of
classes
interfaces
editing tools
classes and interfaces
If a variable is declared as private , then it can be used in _______.
Any class of any package.
Any class of same package.
Only in the same class.
Only subclass in that package.
which package is imported implicitly?
java.applet
java.util
java.lang
java.io
Math class is in ………package.
java.io
java.lang
java.util
java.applet
………………….. package in java contents language utility classes such as vectors, hash tables, random numbers date etc.
java.util
java.awt
java.net
java.lang
…………………….. package in java contents set of classes for implementing graphical user interface, which includes classes for windows, buttons, lists, menus and so on.
java.util
java.awt
java.net
java.lang
Which keyword can protect a class in a package from accessibility by the classes outside the package.
i) private ii) protected iii) final
i only
ii only
iii only
None of the above
Which of the following classes in Java.io package defines a method to delete a file.
Stack
File
String
Vector
The Date class includes within ………………….. package.
java.io
java.awt
java.net
java.util
By convention, java packages begin with ………………. letters while all the class names begin with an ………………… letter.
uppercase, uppercase
lowercase, lowercase
uppercase, lowercase
lowercase, uppercase
Explore all questions with a free account