When a class has-a reference to another class this is referred to as a n relationship

Upgrade to remove ads

Only SGD 41.99/year

  • Flashcards

  • Learn

  • Test

  • Match

  • Flashcards

  • Learn

  • Test

  • Match

Object-Oriented Programming: Inheritance

Terms in this set (45)

_____ is a form of software reusability in which new classes acquire the members of existing classes and embellish those classes with new capabilities.

Inheritance

A superclass's _____ members can be accessed in the superclass declaration and in subclass declarations

public and protected

In a(n) _____ relationship, an object of a subclass can also be treated as an object of its superclass

is-a or inheritance

In a(n) _____ relationship, a class object has references to objects of other classes as members.

has-a or composition

In single inheritance, a class exists in a(n) _____ relationship with its subclasses.

hierarchical

A superclass's _____ members are accessible anywhere that the program has a reference to an object of that superclass or to an object of one of its subclasses.

public

When an object of a subclass is instantiated, a superclass _____ is called implicitly or explicitly

constructor

Subclass constructors can call superclass constructors via the _____ keyword.

super

True or False
Superclass constructors are not inherited by subclasses

True

True or False
A has-a relationship is implemented via inheritance

False.
A has-a relationship is implemented via composition. An is-a relationship is implemented via inheritance

True or False
A Car class has an is-a relationship with the Steering Wheel and Brakes classes

False.
This is an example of a has-a relationship. Class Car has an is-a relationship with class Vehicle.

True or False
When a subclass redefines a superclass method by using the same signature, the subclass
is said to overload that superclass method.

False.
This is known as overriding, not overloading. An overloaded method has the same name, but a different signature

In an inheritance relationship, this is the general class.
a. subclass
b. superclass
c. slave class
d. child class

superclass

In an inheritance relationship, this is the specialized class.
a. superclass
b. master class
c. subclass
d. parent class

subclass

This key word indicates that a class inherits from another class.
a. derived
b. specialized
c. based
d. extends

extends

A subclass does not have access to these superclass members.
a. public
b. private
c. protected
d. all of these

private

This keyword refers to an object's superclass.
a. super
b. base
c. superclass
d. this

super

In a subclass constructor, a call to the superclass constructor must _____.
a. appear as the very first statement
b. appear as the very last statement
c. appear between the constructor's header and the opening brace
d. not appear

appear as the very first statement

The following is an explicit call to the superclass's default constructor.
a . default();
b. class();
c. super();
d. base();

super();

A method in a subclass that has the same signature as a method in the superclass is an example of ____.
a. overloading
b. overriding
c. composition
d. an error

overriding

A method in a subclass having the same name as a method in the superclass but a different signature is an example of ____.
a. overloading
b. overriding
c. composition
d. an error

overloading

These superclass members are accessible to subclasses and classes in the same package.
a. private
b. public
c. protected
d. all of these

protected

All classes directly or indirectly inherit from this class.
a. Object
b. Super
c. Root
d. Java

Object

With this type of binding, the Java Virtual Machine determines at runtime which method to call, depending on the type of the object that a variable references.
a. static
b. early
c. flexible
d. dynamic

dynamic

This operator can be used to determine whether a reference variable references an object of a particular class.
a. isclass
b. typeof
c. instanceof
d. isinstance

instanceof

When a class implements an interface, it must ____.
a. overload all of the methods listed in the interface
b. provide all of the nondefault methods that are listed in the interface, with the exact signatures and return types specified
c. not have a constructor
d. be an abstract class

provide all of the nondefault methods that are listed in the interface, with the exact signatures and return types specified

Fields in an interface are ____.
a. final
b. static
c. both final and static
d. not allowed

both final and static

Abstract methods must be ____.
a. overridden
b. overloaded
c. deleted and replaced with real methods
d. declared as private

overridden

Abstract classes cannot _____
a. be used as superclasses
b. have abstract methods
c. be instantiated
d. have fields

be instantiated

You use the ____ operator to define an anonymous inner class.
a. class
b. inner
c. new
d. anonymous

new

An anonymous inner class must _____
a. be a superclass
b. implement an interface
c. extend a superclass
d. either b or c.

implement an interface
extend a superclass

A functional interface is an interface with _____
a. only one abstract method.
b. no abstract methods.
c. only private methods.
d. no name.

only one abstract method

You can use a lambda expression to instantiate an object that _____.
a. that has no constructor.
b. extends any superclass.
c. implements a functional interface
d. does not implement an interface.

implements a functional interface

True or False:
Constructors are not inherited

False

True or False:
In a subclass, a call to the superclass constructor can only be written in the subclass constructor

True

True or False:
If a subclass constructor does not explicitly call a superclass constructor, Java will not call any of the superclass's constructors.

False

True or False:
An object of a superclass can access members declared in a subclass

False

True or False:
The superclass constructor always executes before the subclass constructor.

True

True or False: When a method is declared with the final modifier, it must be overridden in a subclass.

False

True or False:
A superclass has a member with package access. A class that is outside the superclass's package but inherits from the superclass can access the member.

True

True or False:
A superclass reference variable can reference an object of a subclass that extends the superclass

True

True or False:
A subclass reference variable can reference an object of the superclass

False

True or False:
When a class contains an abstract method, the class cannot be instantiated

True

True or False:
A class may only implement one interface

False

True or False:
By default all members of an interface are public

True

Sets with similar terms

Starting Out With Java 3rd Edition, Tony Gaddis &…

33 terms

Wil_Cleaveland

Chapter 10

33 terms

jasmineofnight

Object-Oriented Programming

24 terms

jkhawaja85

Java Ch20 Ch21 Inheritance & Exceptions and Advanc…

27 terms

teddy_younker

Sets found in the same folder

Java How To Program (late objects) 10e, Ch 10

13 terms

NellyBird

Java How To Program (late objects) 10e, Ch 11

37 terms

NellyBird

Java How To Program (late objects) 10e, Ch 1

41 terms

NellyBird

Java How To Program (late objects) 10e, Ch 8

38 terms

NellyBird

Other sets by this creator

Java How To Program (late objects) 10e

50 terms

NellyBird

Java How To Program (late objects) 10e, Ch 12

91 terms

NellyBird

Access 2016 Comprehensive, 1e Ch 10

24 terms

NellyBird

Access 2016 Comprehensive, 1e Ch 9

28 terms

NellyBird

Verified questions

computer science

True/False. An object may be made up of other objects.

Verified answer

computer science

Describe two different Turing machines, M and N, where M outputs $\langle N\rangle$ and N outputs $\langle M\rangle$, when started on any input.

Verified answer

computer science

True or False? An assembler is a special program that is used to convert mnemonics to its equivalent machine code.

Verified answer

computer science

True or false? Only the _ _init_ _ method can be overridden.

Verified answer

Recommended textbook solutions

When a class has-a reference to another class this is referred to as a n relationship

Information Technology Project Management: Providing Measurable Organizational Value

5th EditionJack T. Marchewka

346 solutions

When a class has-a reference to another class this is referred to as a n relationship

Introduction to Algorithms

3rd EditionCharles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen

726 solutions

When a class has-a reference to another class this is referred to as a n relationship

Fundamentals of Database Systems

7th EditionRamez Elmasri, Shamkant B. Navathe

687 solutions

When a class has-a reference to another class this is referred to as a n relationship

Computer Organization and Design MIPS Edition: The Hardware/Software Interface

5th EditionDavid A. Patterson, John L. Hennessy

220 solutions

Other Quizlet sets

Lange: Ch. 18 General Surgery

157 terms

Naaila_Young

Chapter 2 HW

21 terms

Savannah_Bosley4

Spaans IO6

28 terms

noah_wijnen

Test 1

12 terms

derpysmurphy

Related questions

QUESTION

Which two inventions have allowed programmers to avoid writing programs in machine language

2 answers

QUESTION

The primary limiting factor in the speed of von Neumann architecture computers is called the

3 answers

QUESTION

What type of analysis is used to group data in your dataset which are similar to one another based upon selected characteristics?

3 answers

QUESTION

What is an accommodative foot orthotic?

6 answers

What is the relationship between classes called?

Association. is a broad term that encompasses just about any logical connection or relationship between classes.

When a class on an object of another class then it is which class relationship?

Dependency: An object of one class might use an object of another class in the code of a method. If the object is not stored in any field, then this is modeled as a dependency relationship.

What is is a relationship and has a relationship in Java?

In Java, we have two types of relationship: Is-A relationship: Whenever one class inherits another class, it is called an IS-A relationship. Has-A relationship: Whenever an instance of one class is used in another class, it is called HAS-A relationship.

What is a relationship between a classes and interface?

RELATIONSHIP BETWEEN CLASS AND INTERFACE A class can extend another class, an interface can extend another interface, but a class implements an interface.