-
Notifications
You must be signed in to change notification settings - Fork 6
/
Module 6
177 lines (75 loc) · 2.76 KB
/
Module 6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Module 6 quiz on Object Oriented Programing concepts
1. An object is
The grouping together of data and behavior to create a single entity
The blue print for creating classes
A way to hide implementation details from the user
A sequence of characters
************
Ans:- The grouping together of data and behavior to create a single entity
************
2. A typicial object oriented program
must consist of at least four classes.
uses objects to model the behavior of the ints, chars and boolean variables used in the program.
uses objects to perform most of its useful behavior.
uses methods and primitive data types to perform most of its useful behavior.
************
Ans:- uses objects to perform most of its useful behavior.
***********
3. An example of abstraction would be
supplying the technical drawings with a digital camera.
supplying a Quick Start guide with a digital camera.
supplying batteries with a digital camera.
only selling digital cameras to experienced users.
********************
Ans:-supplying a Quick Start guide with a digital camera.
**********
4. An example of an instance of the City class would be
the variables Name, Latitude, Longitude, Country and Population.
the plans for a city.
the city of Philadelphia.
the methods to update the city's population and to calculate the distance to other cities.
**********
Ans:-
the city of Philadelphia.
*********
5. A class file is (select all that apply)
a file containing a single program or module.
a template or blueprint for an object.
a collection of objects.
a collection of keywords.
*************
Ans:- a file containing a single program or module.
a template or blueprint for an object.
*************
6. A String object is (select all that apply)
a sequence of characters.
Correct
This describes the structure or state of a String.
similar to primitive data types in some respects.
a primitive data type.
a reference to a memory location where data is stored.
*****************************
Ans:- a reference to a memory location where data is stored.
similar to primitive data types in some respects.
********************************
7. Select all of the Java statements that would compile (would not cause an error).
************************************
Ans:-
String str1 = "hi";
String str2 = "HI";
out.println(str1.equals(str2));
out.println("Hello" + " programmers!");
String str1 = "hi";
String str2 = "HI";
out.println(str1 == str2);
*********************************
8. Given the following objects
String str1 = "held";
String str2;
How could you create the string herald?
********************************
Ans:-
str2 = str1.substring(0,2);
str2 = str2 + "ra";
str2 = str2.concat(str1.substring(2,4));
*******************************