,1. Multiple Choice: Which of the following best describes polymorphism in
Java?
A) The ability of a method to be defined in multiple ways
B) The ability of a class to implement multiple interfaces
C) The ability of objects of different classes to be treated as objects of a
common superclass
D) The ability of a class to inherit from multiple classes
Correct Answer: C. Polymorphism in Java allows objects of different
classes to be treated as objects of a common superclass, providing flexibility
and code reusability.
2. Fill in the Blank: In Java, the process of combining data and methods
into a single unit is known as __________.
Correct Answer: Encapsulation. Encapsulation helps in hiding the
internal state of an object and restricting access to certain components.
3. True/False: In Java, the "final" keyword can be used for variables,
methods, and classes to prevent them from being overridden or redefined.
Correct Answer: True. The "final" keyword is used to make variables,
methods, and classes immutable or unchangeable.
4. Multiple Response: Which of the following statements are true regarding
abstract classes in Java? (Select all that apply)
A) An abstract class can be instantiated
B) Abstract classes can have both abstract and concrete methods
, C) Abstract classes can serve as blueprints for other classes
D) An abstract class may not contain any abstract methods
Correct Answer: B, C. Abstract classes can have a mix of abstract and
concrete methods and can be used as base classes for other classes.
5. Multiple Choice: What is the purpose of the 'super' keyword in Java?
A) It refers to the superclass of the current object
B) It is used for type casting objects
C) It denotes an abstract method in a class
D) It is used to invoke a method in the child class
Correct Answer: A. The 'super' keyword is used to refer to the
superclass of the current object, allowing access to superclass members.
6. Fill in the Blank: In Java, the process of defining two or more methods in
a class with the same name but different parameters is known as
__________.
Correct Answer: Method overloading. Method overloading allows
methods with the same names to perform different actions based on the
parameters.
7. True/False: Java does not support multiple inheritance through classes
but allows it through interfaces.
Correct Answer: True. Java supports multiple inheritance through
interfaces by allowing a class to implement multiple interfaces, but not
through classes.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller ClemAcademia. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $17.99. You're not tied to anything after your purchase.