Mphasis Previous Years Solved Sample Placement Papers
-
What is the purpose of the "super" keyword in Java?
A: To refer to the current object
B: To invoke the superclass constructor or methods
C: To create multiple instances of a class
D: To hide data and methods within a class
Ans: B -
What is the purpose of the "this" keyword in Java?
A: To refer to the superclass
B: To create multiple instances of a class
C: To hide data and methods within a class
D: To refer to the current object
Ans: D -
What is the purpose of the "final" keyword in Java?
A: To prevent the inheritance of a class
B: To prevent overriding of a method
C: To prevent modification of a variable's value
D: All of the above
Ans: D -
What is an interface in Java?
A: A class
B: A data type
C: A blueprint for a class
D: A data structure
Ans: C -
Which keyword is used to implement an interface?
A: extends
B: new
C: interface
D: implements
Ans: D -
Can an interface extend another interface in Java?
A: No
B: Yes
Ans: B -
Can an interface have a constructor?
A: Yes
B: No
Ans: B -
Which of the following access modifiers are implicitly applied to variables in an interface?
A: private
B: protected
C: public
D: default
Ans: C -
Is it possible to create an instance of an interface?
A: Yes
B: No
Ans: B -
How many interfaces can a Java class implement?
A: None
B: Only one
C: Two
D: As many as needed
Ans: D -
Can an interface inherit from a class?
A: Yes
B: No
Ans: B -
Can an interface method be declared as final?
A: Yes
B: No
Ans: B -
In Java 9, which type of methods can be added to interfaces to share code between methods?
A: Static
B: Private
C: Final
D: Protected
Ans: B -
An interface with no methods is known as?
A: Abstract Interface
B: Marker Interface
C: Empty Interface
D: Functional Interface
Ans: B -
Which keyword is used to define a default method in an interface?
A: static
B: default
C: final
D: abstract
Ans: B -
Are all methods in an interface abstract?
A: Yes
B: No
Ans: B -
Which of these can be contained in an interface?
A: Abstract methods
B: Constants
C: Default and static methods
D: All of the above
Ans: D -
Which Java feature helps achieve multiple inheritance?
A: Abstract classes
B: Static methods
C: Interfaces
D: Enums
Ans: C -
What is the default access modifier of a method in an interface in Java?
A: private
B: protected
C: public
D: None of the above
Ans: C -
Why were default methods introduced in Java 8 interfaces?
A: To provide multiple inheritance
B: To add utility functions
C: To provide backward compatibility with older interface versions
D: For better performance
Ans: C -
Starting from which Java version can an interface contain method implementations?
A: Java 5
B: Java 7
C: Java 8
D: Java 9
Ans: C -
What is the purpose of the instanceof operator?
A: Multiply instances
B: Compare two object references
C: Check if an object is an instance of a specific class or interface
D: To create a new instance of a class
Ans: C -
Which keyword is used to declare a class variable?
A: volatile
B: transient
C: static
D: final
Ans: C -
Which keyword is used to prevent a class from being inherited?
A: final
B: abstract
C: class
D: extends
Ans: A -
Which keyword is used to create an instance of a class?
A: new
B: return
C: this
D: create
Ans: A -
Which keyword is used to inherit the properties and methods from another class?
A: import
B: package
C: extends
D: implements
Ans: C -
Which keyword is used to refer to the current instance of a class?
A: class
B: this
C: instance
D: object
Ans: B -
Which keyword in Java is used for importing packages into a program?
A: import
B: package
C: include
D: requires
Ans: A