Podcast
Questions and Answers
What is a form of software reusability in which new classes acquire the members of existing classes?
What is a form of software reusability in which new classes acquire the members of existing classes?
Inheritance
A has-a relationship is implemented via inheritance.
A has-a relationship is implemented via inheritance.
False (B)
In a(n) _______ relationship, a class object has references to objects of other classes as members.
In a(n) _______ relationship, a class object has references to objects of other classes as members.
has-a
What is the superclass constructor call syntax?
What is the superclass constructor call syntax?
A superclass's ____________ and ___________ members can be accessed in the superclass declaration and in subclass declarations.
A superclass's ____________ and ___________ members can be accessed in the superclass declaration and in subclass declarations.
Inheritance is sometimes referred to as what?
Inheritance is sometimes referred to as what?
Which statement is true when a superclass has protected instance variables?
Which statement is true when a superclass has protected instance variables?
Superclass constructors are inherited by subclasses.
Superclass constructors are inherited by subclasses.
What type of superclass does a subclass explicitly inherit from?
What type of superclass does a subclass explicitly inherit from?
This access modifier offers an intermediate level of access.
This access modifier offers an intermediate level of access.
In a(n) ______ relationship, an object of a subclass can also be treated as an object of its superclass.
In a(n) ______ relationship, an object of a subclass can also be treated as an object of its superclass.
How can fields labeled private in a superclass be accessed in a subclass?
How can fields labeled private in a superclass be accessed in a subclass?
Superclass methods with this level of access cannot be called from subclasses.
Superclass methods with this level of access cannot be called from subclasses.
Every class in Java, except ________, extends an existing class.
Every class in Java, except ________, extends an existing class.
Subclass constructors can call superclass constructors via the keyword _________.
Subclass constructors can call superclass constructors via the keyword _________.
A Car class has a has-a relationship with the Vehicle class.
A Car class has a has-a relationship with the Vehicle class.
Overriding a method differs from overloading a method because?
Overriding a method differs from overloading a method because?
Choose the answer that lists the complete set of statements that are true:
Choose the answer that lists the complete set of statements that are true:
What is the relationship termed as when a class is derived from another?
What is the relationship termed as when a class is derived from another?
Inheritance is also known as the
Inheritance is also known as the
Private fields of a superclass can be accessed in a subclass
Private fields of a superclass can be accessed in a subclass
In single inheritance, a class exists in a(n) _______________ relationship with its subclasses.
In single inheritance, a class exists in a(n) _______________ relationship with its subclasses.
Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?
Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?
Which of the following statements is (are) true?
Which of the following statements is (are) true?
When a subclass redefines a superclass method by using the same signature, the subclass is said to overload that superclass method.
When a subclass redefines a superclass method by using the same signature, the subclass is said to overload that superclass method.
A superclass object is a subclass object.
A superclass object is a subclass object.
Which of the following is not a superclass/subclass relationship?
Which of the following is not a superclass/subclass relationship?
An advantage of inheritance is that?
An advantage of inheritance is that?
Using the protected keyword gives a member?
Using the protected keyword gives a member?
To avoid duplicating code, use ________, rather than ________.
To avoid duplicating code, use ________, rather than ________.
Which of the following statements describes the state of instance variables after the constructor for class B executes?
Which of the following statements describes the state of instance variables after the constructor for class B executes?
Which superclass members are inherited by all subclasses of that superclass?
Which superclass members are inherited by all subclasses of that superclass?
Failure to prefix the superclass method name with the keyword super and a dot (.) separator when referencing the superclass's method causes what?
Failure to prefix the superclass method name with the keyword super and a dot (.) separator when referencing the superclass's method causes what?
When a subclass constructor calls its superclass constructor, what happens if the superclass's constructor does not assign a value to an instance variable?
When a subclass constructor calls its superclass constructor, what happens if the superclass's constructor does not assign a value to an instance variable?
Which of the following is an example of a functionality that should not be 'factored out' to a superclass?
Which of the following is an example of a functionality that should not be 'factored out' to a superclass?
The default implementation of method clone of Object performs a?
The default implementation of method clone of Object performs a?
The default equals implementation determines?
The default equals implementation determines?
Class ________ represents an image that can be displayed on a JLabel.
Class ________ represents an image that can be displayed on a JLabel.
Which method changes the text the label displays?
Which method changes the text the label displays?
Polymorphism enables you to?
Polymorphism enables you to?
If the superclass contains only abstract method declarations, the superclass is used for?
If the superclass contains only abstract method declarations, the superclass is used for?
Answer by choosing the correct set of true statements:
Answer by choosing the correct set of true statements:
Which of the following does not complete the sentence correctly? An interface
Which of the following does not complete the sentence correctly? An interface
Classes and methods are declared final for all but the following reasons:
Classes and methods are declared final for all but the following reasons:
Classes from which objects can be instantiated are called?
Classes from which objects can be instantiated are called?
Assigning a subclass reference to a superclass variable is safe.
Assigning a subclass reference to a superclass variable is safe.
If a class contains at least one abstract method, it's a(n) ___________ class.
If a class contains at least one abstract method, it's a(n) ___________ class.
For which of the following would polymorphism not provide a clean solution?
For which of the following would polymorphism not provide a clean solution?
All methods in an abstract class must be declared as abstract methods.
All methods in an abstract class must be declared as abstract methods.
Which of the following statements about abstract superclasses is true?
Which of the following statements about abstract superclasses is true?
An interface may contain?
An interface may contain?
To use an interface, a concrete class must specify that it implements the interface and must declare each method in the interface with the signature specified in the interface declaration.
To use an interface, a concrete class must specify that it implements the interface and must declare each method in the interface with the signature specified in the interface declaration.
Which of the following statements about interfaces is false?
Which of the following statements about interfaces is false?
Which statement best describes the relationship between superclass and subclass types?
Which statement best describes the relationship between superclass and subclass types?
Non-abstract classes are called:
Non-abstract classes are called:
Consider classes A, B, and C, where A is an abstract superclass, B is a concrete class that inherits from A, and C is a concrete class that inherits from B. Which of the following statements is true of class C?
Consider classes A, B, and C, where A is an abstract superclass, B is a concrete class that inherits from A, and C is a concrete class that inherits from B. Which of the following statements is true of class C?
Failure to implement a superclass's abstract methods in a subclass is a compilation error unless the subclass is also declared abstract.
Failure to implement a superclass's abstract methods in a subclass is a compilation error unless the subclass is also declared abstract.
Polymorphism allows for specifics to be dealt with during?
Polymorphism allows for specifics to be dealt with during?
Consider the abstract superclass below: public abstract class Foo { private int a; public int b; public Foo( int aVal, int bVal ) { a = aVal; b = bVal; } public abstract int calculate(); } Any concrete subclass that extends class Foo:
Consider the abstract superclass below: public abstract class Foo { private int a; public int b; public Foo( int aVal, int bVal ) { a = aVal; b = bVal; } public abstract int calculate(); } Any concrete subclass that extends class Foo:
Which keyword is used to specify that a class will define the methods of an interface?
Which keyword is used to specify that a class will define the methods of an interface?
All of the following methods are implicitly final except:
All of the following methods are implicitly final except:
This type of class cannot be a superclass.
This type of class cannot be a superclass.
It is a UML convention to denote the name of an abstract class in?
It is a UML convention to denote the name of an abstract class in?
A(n) class cannot be instantiated.
A(n) class cannot be instantiated.
Which of the following could be used to declare abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)?
Which of the following could be used to declare abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)?
When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at?
When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at?
Every object in Java knows its own class and can access this information through the method?
Every object in Java knows its own class and can access this information through the method?
Declaring a method final means?
Declaring a method final means?
The UML distinguishes an interface from other classes by placing the word 'interface' in?
The UML distinguishes an interface from other classes by placing the word 'interface' in?
Interfaces can have methods.
Interfaces can have methods.
Which of the following is not possible?
Which of the following is not possible?
A class that implements an interface but does not declare all of the interface's methods must be declared?
A class that implements an interface but does not declare all of the interface's methods must be declared?
Constants declared in an interface are implicitly?
Constants declared in an interface are implicitly?
In a class diagram, properties may be related to the instance variables of a class.
In a class diagram, properties may be related to the instance variables of a class.
It is permissible to leave get and set methods for the instance variables of a class out of the class diagram.
It is permissible to leave get and set methods for the instance variables of a class out of the class diagram.
Which of the following statements describe the type(s) of relationships that may be described by class diagrams?
Which of the following statements describe the type(s) of relationships that may be described by class diagrams?
Operations in a class diagram correspond to _____ in Java.
Operations in a class diagram correspond to _____ in Java.
The proper way to indicate that a class property may have no value entered into it is ____________.
The proper way to indicate that a class property may have no value entered into it is ____________.
Which of the following may be represented in a class diagram?
Which of the following may be represented in a class diagram?
The UML syntax for operations includes which of the following:
The UML syntax for operations includes which of the following:
The features of a class can refer to both properties and operations.
The features of a class can refer to both properties and operations.
Which of the following may be found in an attribute notation (select all that apply)?
Which of the following may be found in an attribute notation (select all that apply)?
Whether an operation is public or private is indicated by either + for private or - for public.
Whether an operation is public or private is indicated by either + for private or - for public.
Something a business must track or that participates in the business may generally be called?
Something a business must track or that participates in the business may generally be called?
Which of the following should be visible to other objects?
Which of the following should be visible to other objects?
Another way to talk about a superclass is?
Another way to talk about a superclass is?
The acronym OMG (when discussing UML) stands for which of the following?
The acronym OMG (when discussing UML) stands for which of the following?
Polymorphism refers to the ability of _________ to take many 'shapes'.
Polymorphism refers to the ability of _________ to take many 'shapes'.
A subclass may add attributes, operations, and relationships to those inherited from the superclass.
A subclass may add attributes, operations, and relationships to those inherited from the superclass.
Polymorphism allows a subclass to override operations of a superclass, thus specializing the operation for the subclass.
Polymorphism allows a subclass to override operations of a superclass, thus specializing the operation for the subclass.
The UML standard is owned by which of the following?
The UML standard is owned by which of the following?
An object of a subclass automatically?
An object of a subclass automatically?
If two objects belong to the same class, which of the following statements about those objects is true?
If two objects belong to the same class, which of the following statements about those objects is true?
A superclass defines a method called findArea. A subclass of that superclass also defines a method called findArea, but the subclass method uses a different formula. This is an example of ________.
A superclass defines a method called findArea. A subclass of that superclass also defines a method called findArea, but the subclass method uses a different formula. This is an example of ________.
A 'method' is?
A 'method' is?
Two things that must be remembered about specific objects are (select two):
Two things that must be remembered about specific objects are (select two):
The ways objects may be related are?
The ways objects may be related are?
Attributes and operations defined at the class level will be shared by all objects of that class.
Attributes and operations defined at the class level will be shared by all objects of that class.
Study Notes
Inheritance and Relationships
- Inheritance allows new classes to inherit properties and methods from existing classes, enhancing functionality.
- A has-a relationship indicates composition, not inheritance, which defines relationships where a class contains references to other classes.
- An is-a relationship means a subclass can be treated as an object of its superclass.
Access Modifiers
- Protected members can be accessed by subclasses and other classes within the same package.
- Public members are accessible everywhere, whereas private members of a superclass can only be accessed through public or protected methods.
Constructors
- Superclass constructors are not inherited; subclasses must call them explicitly using the
super
keyword. - When invoking an abstract superclass, subclasses must implement the abstract methods or also be declared abstract.
Abstract Classes and Interfaces
- Abstract classes can include both abstract methods and concrete methods and cannot be instantiated directly.
- Interfaces only define abstract methods (implicitly public) and constants (implicitly static final) and cannot be instantiated.
Polymorphism
- Polymorphism allows methods to be overridden, enabling subclasses to provide specific implementations of superclass methods.
- Late binding refers to method resolution at runtime, allowing subclass methods to be called when using superclass references.
UML and Class Diagrams
- UML notation distinguishes between classes and interfaces by formatting, using italics for abstract classes and guillemets for interfaces.
- Class diagrams represent relationships like inheritance, composition, and define properties (attributes) and behaviors (methods) of classes.
Relationships in Java
- Relationships between classes include association, aggregation, and composition, determining how objects interact and are linked.
- Subclass objects inherit all attributes and methods from their superclass and can define additional features, enhancing reusability and reducing redundancy.
Truths About Classes and Objects
- Objects of the same class share the same operational procedures but may hold different attribute values.
- Declaring a method as final prevents it from being overridden, maintaining its original behavior across subclasses.
Important Concepts in Java
- The
super
keyword is essential for accessing superclass methods and constructors from within subclasses, especially when methods are overridden. - Constructors of subclasses must always call their direct superclass constructor as their first task, ensuring proper initialization of inherited attributes.
Key Definitions
- Concrete classes can be instantiated, unlike abstract classes which provide foundational structures but require derived classes to implement specifics.
- Business objects reflect entities of interest within a business context and must expose certain operations while encapsulating their attributes.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge with these flashcards designed for the IS2043 Exam One. Topics covered include software reusability, inheritance, and class relationships. Perfect for reinforcing key concepts in your software development studies.