Exposure Java Multiple Choice Test Chapter 8 Introduction to OOP, Encapsulation

oatmealbrothersΛογισμικό & κατασκευή λογ/κού

18 Νοε 2013 (πριν από 3 χρόνια και 11 μήνες)

2.410 εμφανίσεις

Exposure Java 2008 CS Edition Chapter Test 8 11
-
01
-
08
Page
1


Exposure Java

Multiple Choice Test

Chapter 8

Introduction to OOP, Encapsulation

REVIEW



Objective 1
-

Introduction to OOP



01.

Which of the programming features is
/are

part of Object Oriented Programming?


Encapsulation

Polymorphism

Inheritance



02.

What is the essence of encapsulation?


Combining data and the action modules that access the data inside the same module.


03.

Object members that perform some

specified

task are called

methods.




04.

Object members that store data are called


attri
butes.


05.

O
bject attribute
s

behave like

noun
s
.


06.

O
bject
methods

behave

like

verb
s
.


07.

Think about the GridWorld Case Study lab assignment
s

that you have completed.


Assume that the grid displays 4 bugs and 3 rocks.


How many classes and objects
are shown?


2 classes and 7 objects


08.

Think about the GridWorld Case Study lab assignment that you have completed.


Assume that the grid displays 1 bug, 2 rocks, 7 flowers and 3 actors.


How many classes and objects are shown?


4 classes and 13 objects


09.

What
is

true about the
Cryptic Programming Stage
?

Computers were extremely expensive.

Programmer salaries were very low.

Programs were not designed
for future updates.


10.

Spaghetti Programming

is categorized by the use of


the
goto
statement.


11.

Structured Programming

is categorized by the use of


modules to combine program statements used for a common purpose.


Exposure Java 2008 CS Edition Chapter Test 8 11
-
01
-
08
Page
2


12.

Object Oriented Programming

is categorized by the use of

classes and objects.


13.

Object Oriented Programming is designed

to make a program

easier to develop.

simpler to debug.

faster to test with confidence.


14.

How does the
oopified
airport

analogy

increase reliability?


The passenger check
-
in counter is dedicated to one destination only.

There is a single conveyor belt
that
carries luggage to a single gate.

Passengers cannot cross over and end up at the wrong departure gate.


15.

Why was
structured programming

no longer reliable with modern program development?


The complex windows
-
graphics
-
style programs brought a new
challenge in reliability.


16.

The
lumber delivery object
analogy increases delivery reliability
by

delivering the entire lumber order on the same day.


1
7.

Calling a class method requires using


a

class identifier followed by a dot and a method identifier.


1
8.

Calling an object method requires using


an object identifier followed by a dot and a method identifier.


19.

Which statement is
true

about comparing class methods and object methods?



Class methods are easier to create than object methods.


Class method headings use the
static
keyword. Object methods do not use
static
.


Object methods can only be called after an object is constructed with the
new
keyword.


All of the above


20.

Which statement is
false

about comparing class methods and object methods?


Class methods require parameter information. Object methods do not use parameters.


21.

Without the use of a
public
or
private
declaration, access to data and methods is


availab
le to methods of the same class and other classes.


22.

Access to
private
data or
private
methods is


restricted to methods of the same class.


23.

Access to
public
data or
public
methods is


available to methods of the same class and other classes.


24.

The use of
private
in a class declaration


creates greater program reliability.


2
5
.

Which operator is used to construct a new object?

new


2
6
.

Which feature

can you use to recognize constructor methods in a class declaration?


Exposure Java 2008 CS Edition Chapter Test 8 11
-
01
-
08
Page
3



The constructor
identifier is the same as the class identifier.


2
7
.

When is a constructor called?

During the instantiation of a new object


2
8
.

A class can have


multiple constructors with the same identifier.


29
.

What is an
overloaded
constructor?


A second
constructor with a different

heading

signature than
the first
constructor.


30
.

Constructor methods are


called during the instantiation of a new object.


used
primarily

to initialize data attributes of a new object.


neither
void
methods nor
return
methods.


31
.

Which of the following method declarations can be a constructor?



I.


public static void Qwerty()




{





start = 0;





max = 1000;




}



II.

public Qwerty()




{





start = 0;





max = 1000;




}



III.

public Qwerty(int s, int m)




{





start = s;





max = m;




}






I
I

& III only


32
.

Which of the following statements calls a constructor method where
Qwerty

is a class identifier?



Qwerty = new balloon();


Qwerty.balloon();


Qwerty balloon = new Qwerty();


balloon = new Qwerty;


33
.

A
class
method


requires using the keyword
static
.


Exposure Java 2008 CS Edition Chapter Test 8 11
-
01
-
08
Page
4


3
4
.

An
object
method



requires using the keyword
new
.


3
5
.

A
private
method




I.


can only be accessed by methods of the same class.


II.

is
usually
a helper method.


III.

can

never be a constructor.


I, II & III



3
6
.

A
public
method




I.


can only access public data.



II.

can be

a constructor.


III.

can be accessed from outside the class.





I
I
& III only



3
7
.

A
void
method

can also be


a
static
method.

a
public
method.

a
private

method.


3
8
.

A
return
method


indicates the data type of the return value.

uses the keyword
return
.

3
9
.

A
default
constructor

is a



no
-
parameter
method, which is called automatically during the instantiation of a new object.


40
.

A
parameter
constructor

is a

parameter
method, which is called automatically during the instantiation of a new object.