java programming

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

"Explain inheritance."

"Inheritance means that objects of one class can derive state and/or behavior from another (base or parent) class."

"What is the common superclass from which all Java classes derive directly or indirectly?"

"Object."

"Explain encapsulation."

"Packing of data and functions into a single component."

"What does the *default toString() method* implementation do?"

"Returns the class name"

"Explain polymorphism."

"This ability of different but related objects to respond, each in its own way, to identical messages is called polymorphism."

What does the greek word polymorphism mean?

"changeable".

"Where would you use the keyword extends and implements?"

"extends is the keyword used to declare that this class is a subclass of the class that follows the extends keyword. Implements is a keyword that designates this class as an implementer of the specified interface."

"Which operator checks the type of an object?"

"instanceof"

Polymorphism means ...

"many forms", in other words subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class.

Which two reference types *cannot be instantiated*?

*Abstract classes and interfaces*

How many interfaces can a class extend directly?

*As many as it needs.*

What is a *composition association*?

*Composition association* is used to describe relationships where *an object is composed of one or more objects*. The internal object makes sense only while stored in the internal object.

What is a *direct association* relationship?

*Direct association* describes a *"has a" relationship*. This is a basic association that represents navigability. Direct association is a *weak relationship* and therefore can be generalized to an association. The containing object also has the responsibility of managing the life cycle of the internal object.

How many classes can a class extend?

*Only one!*

Is polymorphism unidirectional or bidirectional?

*Unidirectional*. More specific objects can act polymorphically only as more general objects.

Which keyword is used to access superclass members within a subclass?

*super*

How many classes can a subclass extend directly?

1

*IS-A* is equivalent to following expressions:

1) "inherits from"

What two characteristics separate different overloaded methods

1) Number of parameters and

Polymorphism allows an object to be referred to as?

1. any base class it *extends*

subclass

A class below another class in a class hierarchy. A class that inherits another class.

What conditions must a method meet to be an overridden one?

A derived class is said to override a method in the base class if it defines a method with the same name, same parameter list, and same return type as in the derived class.

derived class

A subclass.

base class

A superclass.

Aggregation

Aggregation is a special case of association. A directional association between objects. When an object 'has-a' another object, then you have got an aggregation between them. Direction between them specified which object contains the other object. Aggregation is also called a "Has-a" relationship.

Inheritance provides which of the following?

Allows developers to place general code in a class that more specific classes can gain through inheritance. Also promotes code reuse.

What is an aggregation association?

An aggregation association is a relationship that represents one object being part of another object. An aggregation association represents a "part of" the whole relationship. In this relationship, even though one is part of the other, each object can maintain its own meaning independently.

Initialization

An assignment that gives an initial value to a variable that will be updated.

Association

Association is a relationship between two objects. In other words, association defines the multiplicity between objects. You may be aware of one-to-one, one-to-many, many-to-one, many-to-many all these words define an association between objects. Aggregation is a special form of association. Composition is a special form of aggregation.

Composition

Composition is a special case of aggregation. In a more specific manner, a restricted aggregation is called composition. When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition.

Difference between aggregation and composition

Composition is more restrictive. When there is a composition between two objects, the composed object cannot exist without the other object. This restriction is not there in aggregation. Though one object can contain the other object, there is no condition that the composed object must exist. The existence of the composed object is entirely optional. In both aggregation and composition, direction is must. The direction specifies, which object contains the other object.

Does polymorphism make objects more specific or general?

General

Inheritance is a key concept that underlies ...

IS-A, polymorphism, overriding (not "overloading") and casting. Having one class as a parent class (called a super class) and another class as a child of the parent (the sub class).

How many interfaces can a class implement?

Infinity

What is used to place a common code in a base class?

Inheritance

What makes code more modular and easier to maintain?

Inheritance

Which class is the implicit superclass of all classes?

Object

What is an overloaded method?

Overloaded methods accept different lists of arguments. The argument lists can differ by:

What allows one object to act as either one of its superclasses or as an interface that it implements?

Polymorphism

What is a fundamental concept of object-oriented languages like JAVA and stimulates code reuse?

Polymorphism

Given SuperClass obj = new SubClass(), what is the *object type* of obj?

SubClass

Which declaration for SubClass indicates its superclass is SuperClass?

SubClass extends SuperClass

What is the name of the class the gains functionality from another class?

Subclass

Given SuperClass obj = new SubClass(), what is the *reference type* of obj?

SuperClass

inheritance

The OOP property in which a class can define a specialized type of an already existing class

polymorphism

The OOP property in which objects

extends

The keyword used in a class declaration to

Instantiate

The process of creating a new object and assigning it a value.

Explain "Reference Type" and "Object Type"

The reference type corresponds to the type in a variable declaration. The object type corresponds to the instantiated class in an object variable declaration. So "reference type" is the LHS type and "object type" is the actual instantiated type on the RHS of an object variable declaration.

superclass

The upper-most class in a class hierarchy.

In an object variable, what does the reference type determine?

The visibility of subtype members

override

To *redefine a method* from a superclass in a subclass.

inherit

To receive the methods of a superclass.

True or False: A class that is inherited is called a parent or base class.

True.

What is meant by method overloading?

Two or more methods have the same name, but specify a different order or data types for parameters.

Can a class implement multiple interfaces.

Yes

HAS-A means ...

an instance of one class "has a" reference to an instance of another class or another instance of the same class.

extended classes can be used

as a basis for any other class

*HAS-A* relationship is demonstrated

by a *class that contains another class*.

*IS-A* relationship is demonstrated

by a class derived from an existing class.

instanceOf

check if an object is an instance of a specific class

HAS-A refers to ...

composition.

What keyword is used to extend or inherit a class?

extends

Which keyword is used to declare a subclass of an existing class?

extends

IS-A is expressed with the keyword ...

extends.

Which keyword is used declare a class that provides interface implementation?

implements

____ keyword is used by classes by inherit from interfaces. Interfaces can never be extended by the classes.

implements

*IS-A* refers to ...

inheritance.

Which operator determines whether an object matches a reference type or one of its supertypes?

instanceof

A single class can implement ...

many interfaces.

What is polymorphism commonly used for?

method arguments

You implement an interface by properly and concretely ...

overriding all of the methods defined by the interface.

*Polymorphism* applies to ...

overriding, not to overloading.

class X is the subcalss

public class *X extends Z* {}

If A is a class.....B and C are interfaces, what is the proper signature for class A implements interfaces B and C?

public class A implements B, C {}

Which declaration for concrete class B indicates it implements the interface A?

public class B implements A {

Overloading means ...

reusing a method name, but with different arguments.

All classes (except class Object), are ...

subclasses of type Object, and therefore they inherit Object's methods.

In as 'IS-A' relationship how do the sub and super classes work together?

the *subclass object 'IS-A'* superclass object.

In a variable, what corresponds to the instantiated class?

the object type

In a variable, what corresponds to the type in the variable declaration?

the reference type

*IS-A* relationship

the relationship between an object and the class of which it is a member

Reference type determines ...

which overloaded method will be used at compile time.


Set pelajaran terkait

Macro Practice Questions, Chapter-End Questions CHAPTER 30

View Set

Medical Assisting : Medical Law and Ethics Chapter 3

View Set

MGT 321 Exam #1: Chapter 1, 2, 3, and 11

View Set

Live Virtual Machine Lab 3.1: Module 03 Internet Protocol Addressing Solutions

View Set

Light Lesson Exam Study Guide (5th Grade)

View Set

Test 1 - 2402 Anatomy & Physiology - Spring 2019

View Set