Worksheetsoops
Total questions: 10
Worksheet time: 5mins
Which statement about Java classes is true?
A class must always contain a main method
A class can have multiple constructors
A class can’t have private fields
An object can be created without a class
Which members are not inherited by a subclass?
Constructors
Private fields
Static methods
Both (a) and (b)
B can override A’s private methods
If class B extends class A, what is correct?
B can call A’s constructor directly
B automatically inherits all public and protected members
B cannot access A’s fields at all
What is method overriding?
a) Same method name, different return type, same class
b) Same method name, different parameters, same class
c) Same method name, same parameters, different class (inherited)
d) Different method name, same class
Which is runtime polymorphism?
a) Method Overloading
b) Method Overriding
c) Constructor Overloading
d) Static method hiding
Which is true about interfaces?
a) A class can implement multiple interfaces
b) An interface can extend multiple interfaces
c) An interface can extend a class
d) Both a and b
When an object is created:
a) Only methods are loaded into memory
b) Only data members are loaded into memory
c) Both data members and methods are loaded
d) Only constructor is loaded
Which one is not polymorphism?
a) Method overloading
b) Method overriding
c) Operator overloading
d) Interface implementation
Which statement is true?
a) Abstract class supports multiple inheritance
b) Interface supports multiple inheritance
c) Both class & interface support multiple inheritance
d) None support multiple inheritance
Which is valid declaration?
a) abstract final class Test {}
b) public abstract class Test {}
c) static abstract class Test {}
d) private abstract class Test {}
