CP Spring Final Exam

CP SPRING FINAL EXAM
01.
How is C++ different from Java?
(A)
(B)
(C)
(D)
02.
Which of the following is a feature incorporated by OOP?
(A)
(B)
(C)
(D)
03.
Encapsulation
Polymorphism
Class Interaction
All of the Above
Which of the following combines attributes and methods in one container?
(A)
(B)
(C)
(D)
04.
C++ has OOP. Java does not.
Java has OOP. C++ does not.
With C++, OOP is optional. With Java, OOP is required.
With Java, OOP is optional. With C++, OOP is required.
Encapsulation
Polymorphism
Class Interaction
All of the Above
Which of the following stores information for an object?
(A)
(B)
(C)
(D)
attributes
classes
methods
All of the Above
05.
Which of the following are the actions an object can perform?
(A)
(B)
(C)
(D)
attributes
classes
methods
All of the Above
06.
System, Math, Expo, DecimalFormat and Bank are all examples of
(A)
(B)
(C)
(D)
attributes.
classes.
methods.
All of the Above
07.
println, sqrt, drawCircle, enterInt and checkingDeposit are all examples of
(A)
(B)
(C)
(D)
08.
PI and E are examples of
(A)
(B)
(C)
(D)
09.
Computers were extremely expensive and very difficult to program.
The goto statement was used as a quick fix when programs did not work.
The philosophy of one-task-one-module came about.
This is the style of programming we use today.
Which of the following describes the Structured Programming Stage?
(A)
(B)
(C)
(D)
12.
Computers were extremely expensive and very difficult to program.
The goto statement was used as a quick fix when programs did not work.
The philosophy of one-task-one-module came about.
This is the style of programming we use today.
Which of the following describes the Unstructured Programming Stage?
(A)
(B)
(C)
(D)
11.
attributes
classes
methods
All of the Above
Which of the following describes the Cryptic Programming Stage?
(A)
(B)
(C)
(D)
10.
attributes
classes
methods
All of the Above
Computers were extremely expensive and very difficult to program.
The goto statement was used as a quick fix when programs did not work.
The philosophy of one-task-one-module came about.
This is the style of programming we use today.
Which of the following describes Object Oriented Programming?
(A)
(B)
(C)
(D)
Computers were extremely expensive and very difficult to program.
The goto statement was used as a quick fix when programs did not work.
The philosophy of one-task-one-module came about.
This is the style of programming we use today.
13.
Use of the goto statement lead to what expression?
(A)
(B)
(C)
(D)
14.
How does the heading of a void class method begin?
(A)
(B)
(C)
(D)
(E)
15.
public static void
public static datatype
public void
public datatype
public the name of the class
How does the heading of a void object method begin?
(A)
(B)
(C)
(D)
(E)
17.
public static void
public static datatype
public void
public datatype
public the name of the class
How does the heading of a return class method begin?
(A)
(B)
(C)
(D)
(E)
16.
"Modular Programming"
"Spaghetti Programming"
"Structured Programming"
"Object Oriented Programming"
public static void
public static datatype
public void
public datatype
public the name of the class
How does the heading of a return object method begin?
(A)
(B)
(C)
(D)
(E)
public static void
public static datatype
public void
public datatype
public the name of the class
18.
How does the heading of a constructor begin?
(A)
(B)
(C)
(D)
(E)
19.
What is the single most important goal for any program?
(A)
(B)
(C)
(D)
20.
public static void
public static datatype
public void
public datatype
public the name of the class
That the program is fast.
That the program is cheap.
That the program is readable.
That the program is reliable.
Object members that are declared _______ can only be accessed in the class in which they are declared.
(A) public
(B) private
21.
_______ is the process of using features (both attributes and actions) from an established higher class.
(A)
(B)
(C)
(D)
(E)
022.
_______ is the process of combining the data with the methods that act on that data in one container.
(A)
(B)
(C)
(D)
(E)
023.
Encapsulation
Instantiation
Polymorphism
Composition
Inheritence
Encapsulation
Instantiation
Polymorphism
Composition
Inheritence
Assume class B inherits from class A.
What is the exact Java code for the first line of class A?
(A)
(B)
(C)
(D)
class A
class B
class A extends B
class B extends A
024.
Assume class B inherits from class A.
What is the exact Java code for the first line of class B?
(A)
(B)
(C)
(D)
025.
class A
class B
class A extends B
class B extends A
If class B inherits from class A, class B is called the _______.
(A) subclass
(B) superclass
026.
If class B inherits from class A, class A is called the _______.
(A) subclass
(B) superclass
027.
_______ is used to describe an is-a relationship.
(A)
(B)
(C)
(D)
(E)
028.
_______ is used to describe a has-a relationship.
(A)
(B)
(C)
(D)
(E)
029.
Encapsulation
Instantiation
Polymorphism
Composition
Inheritence
Encapsulation
Instantiation
Polymorphism
Composition
Inheritence
What is the following sentence an example of?
A student is a person.
(A)
(B)
(C)
(D)
inheritance
composition
Both inheritance and composition
Neither inheritance, nor composition
30.
What is the following sentence an example of?
A student has a schedule.
(A)
(B)
(C)
(D)
31.
inheritance
composition
Both inheritance and composition
Neither inheritance, nor composition
What is the following sentence an example of?
A tire-swing is a swing that has a tire.
(A)
(B)
(C)
(D)
32.
If class C inherits from class B and class B inherits from class A, you have _______.
(A)
(B)
(C)
(D)
33.
inheritance
composition
Both inheritance and composition
Neither inheritance, nor composition
multi-level inheritance
multi-level composition
multiple inheritance
multiple composition
What is the following sentence an example of?
A square is a rectangle; a rectangle is a parallegogram; a parallelogram is a quadralateral;
and a quadralateral is a polygon.
(A)
(B)
(C)
(D)
34.
multi-level inheritance
multi-level composition
multiple inheritance
multiple composition
What is the following sentence an example of?
A dinosaur is a reptile, and a dinosaur is extinct.
(A) multi-level inheritance
(B) multi-level composition
(C) multiple inheritance
(D) multiple composition
35.
Which of the following is possible in C++, but NOT in Java?
(A)
(B)
(C)
(D)
36.
multi-level inheritance
multi-level composition
multiple inheritance
multiple composition
Does a subclass have access to the private attributes of the superclass?
(A) yes
(B) no
37.
Does a subclass have access to the public attributes of the superclass?
(A) yes
(B) no
38.
Does a subclass have access to the protected attributes of the superclass?
(A) yes
(B) no
39.
The has-a relationship describes
(A)
(B)
(C)
(D)
40.
inheritance.
encapsulation.
polymorphism.
composition.
The is-a relationship describes
(A)
(B)
(C)
(D)
inheritance.
encapsulation.
polymorphism.
composition.
41.
Which boolean operator has this definition?
At least one of the conditions must be true.
(A)
(B)
(C)
(D)
042.
AND
OR
XOR
NOT
Which boolean operator has this definition?
Exactly one of the conditions must be true.
(A)
(B)
(C)
(D)
043.
AND
OR
XOR
NOT
Which boolean operator has this definition?
Both conditions must be true.
(A)
(B)
(C)
(D)
044.
Which boolean operator will give you the opposite of a condition?
(A)
(B)
(C)
(D)
045.
AND
OR
XOR
NOT
AND
OR
XOR
NOT
Which boolean operation is
represented by this truth table?
(A)
(B)
(C)
(D)
(E)
P and Q
P or Q
P xor Q
not P
not Q
P
Q
???
T
T
T
T
F
T
F
T
T
F
F
F
046.
Which boolean operation is
represented by this truth table?
(A)
(B)
(C)
(D)
(E)
047.
P and Q
P or Q
P xor Q
not P
not Q
Which boolean operation is
represented by this truth table?
(A)
(B)
(C)
(D)
(E)
P and Q
P or Q
P xor Q
not P
not Q
P
Q
???
T
T
T
T
F
F
F
T
F
F
F
F
P
Q
???
T
T
F
T
F
F
F
T
T
F
F
T
048. Which boolean operation is
represented by this truth table?
(A)
(B)
(C)
(D)
(E)
049.
Which boolean operation is
represented by this truth table?
(A)
(B)
(C)
(D)
(E)
50.
P and Q
P or Q
P xor Q
not P
not Q
P and Q
P or Q
P xor Q
not P
not Q
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
A
B
not A
not B
P
Q
???
T
T
F
T
F
T
F
T
T
F
F
F
P
Q
???
T
T
F
T
F
T
F
T
F
F
F
T
51.
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
52.
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
53.
A
B
not A
not B
A
B
not A
not B
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
A
B
not A
not B
54.
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
(E)
55.
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
(E)
56.
A or B
A and B
not (A or B)
not (A and B)
A xor B
A or B
A and B
not (A or B)
not (A and B)
A xor B
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
(E)
A or B
A and B
not (A or B)
not (A and B)
A xor B
57.
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
(E)
58.
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
(E)
59.
A or B
A and B
not (A or B)
not (A and B)
A xor B
A or B
A and B
not (A or B)
not (A and B)
A xor B
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
(E)
A and (not B)
B and (not A)
A or (not B)
B or (not A)
not(A xor B)
60.
Which of the following is
represented by this Venn Diagram?
(A)
(B)
(C)
(D)
(E)
061.
A and (not B)
B and (not A)
A or (not B)
B or (not A)
not(A xor B)
A data type that stores only a single value is called what?
(A)
(B)
(C)
(D)
062.
A data type that stores multiple values and methods is called what?
(A)
(B)
(C)
(D)
063.
Simple/Primitive
Advanced
Modern
Data Structure
A one-dimensional array is frequently called a _______.
(A)
(B)
(C)
(D)
(E)
064.
Simple/Primitive
Advanced
Modern
Data Structure
file
matrix
record
vector
stack
A two-dimensional array is frequently called a _______.
(A)
(B)
(C)
(D)
(E)
file
matrix
record
vector
stack
065.
A _______ is a data structure with one, or more, elements, called fields, of the same or different data
types.
(A)
(B)
(C)
(D)
066.
An object is essentially a _______ that can also store methods.
(A)
(B)
(C)
(D)
067.
array
file
record
stack
The first historical data structure is the _______.
(A)
(B)
(C)
(D)
70.
array
file
record
stack
Which data structure behaves in a LIFO manner?
(A)
(B)
(C)
(D)
069.
array
file
record
stack
The _______ data structure allows transfer of data between internal and external storage.
(A)
(B)
(C)
(D)
068.
array
file
record
stack
array
file
record
stack
The _______ data structure was introduced with the language FORTRAN.
(A)
(B)
(C)
(D)
array
file
record
stack
71.
The _______ data structure was introduced with the language COBOL.
(A)
(B)
(C)
(D)
72.
array
file
record
stack
How is an array different from a stack?
(A)
An array can store fixed elements of the same type.
A Stack can store elements of different types.
(B)
An array can store elements of different types.
A Stack can store fixed elements of the same type.
(C)
Every element of an array can be accessed directly.
Only the top element of a stack can be accessed.
(D)
Every element of an stack can be accessed directly.
Only the top element of a array can be accessed.
73.
What is the output of this program segment:
int list[] = {10,20,30,40,50,60,70,80,90};
System.out.println( list[0] );
(A)
(B)
(C)
(D)
(E)
10
20
30
40
Error
74.
What is the output of this program segmen
int list[] = {10,20,30,40,50,60,70,80,90};
System.out.println( list[1] );
(A)
(B)
(C)
(D)
(E)
10
20
30
40
Error
75.
What is the output of this program segment:
int list[] = {10,20,30,40,50,60,70,80,90};
System.out.println( list[7] );
(A)
(B)
(C)
(D)
(E)
76.
60
70
80
90
Error
What is the output of this program segment:
int list[] = {10,20,30,40,50,60,70,80,90};
System.out.println( list[8] );
(A)
(B)
(C)
(D)
(E)
77.
60
70
80
90
Error
What is the output of this program segment:
int list[] = {10,20,30,40,50,60,70,80,90};
System.out.println( list[9] );
(A)
(B)
(C)
(D)
(E)
78.
60
70
80
90
Error
When working with Java static arrays, is length a method or a field?
(A)
(B)
method
field
79.
What is the output of this program segment:
int list[] = new int[10];
for (int j = 0; j < 10; j++)
System.out.print( list[j] );
(A)
(B)
(C)
(D)
(E)
80.
0
0000000000
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
10 unknown numbers
Error
What is the output of this program segment:
int list[] = new int[10];
System.out.println( Arrays.toString(list) );
(A)
(B)
(C)
(D)
(E)
0
0000000000
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
10 unknown numbers
Error