oOP Flashcards

1
Q

are the variables that each object (each instance of a class) has as part of itself.

A

instance variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

means they are accessible only to the object itself.

A

private,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

returns a reference to the object it constructs

A

constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Parameter names follow the same rules as the other names you might pick for a program. Names of this type are called

A

this

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

is a variable that holds part of the state of an object.

A

instance variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In Java, a characteristic of a class that is not part of its objects

A

static.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can the static main() method invoke other static methods of the class?

A

Yes. Static methods can call other static methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Will parameter passing be the same as with the instance methods of the previous chapters?

A

Yes. Static methods pass data to other static methods through parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The program keeps looping until the user signals the end. What type of loop is this?

A

A sentinel controlled loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the parameter of the method that calculates factorial?

A

The value of N, an integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the return value of the method that calculates factorial?

A

The factorial of N.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

is an incomplete version of a method that is used in place of the full method. Extremely useful when developing programs.

A

stub

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

let you test individual methods. This can be very useful.

A

unit testing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

is one whose data does not change.

A

immutable object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The arguments in a method call are often referred to as ____.

A

actual parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A(n) ____ method is a method that creates and initializes class objects.

A

constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

____ is the encapsulation of method details within a class.

A

Implementation hiding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

When a variable ceases to exist at the end of a method, programmers say the variable____.

A

goes out of scope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Method names that begin with “____” and “set” are very typical.

A

get

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Public classes are accessible by all objects, which means that public classes can be

A

extend or/and used as a basis

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Assigning ____to a field means that no other classes can access the field’s values.

A

private access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Methods used with object instantiations are called ____ methods.

A

instance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Methods that retrieve values are called ____ methods.

A

accessors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

A(n) unique identifier is most likely used as a(n) ____ key in a database.

A

primary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
For ease in locating class methods, many programmers store them in ____ order.
alphabetical
26
A(n) ____ constructor is one that requires no arguments.
default
27
A(n) ____ is a program module that contains a series of statements that carry out a task.
method
28
The method ____ is the first line of a method.
declaration
29
executes first in an application, no matter where you physically place it within its class.
main method
30
Data items you use in a call to a method are called ____.
arguments
31
A(n) ____ variable is known only within the boundaries of the method.
local
32
A(n) _____ causes a value to be sent from a called method back to the calling method.
return statement
33
An object is a(n) ____ of a class.
member
34
for a class, you no longer have access to the automatically created version.
when you write a constructor
35
You are ____ required to write a constructor method for a class.
never
36
To execute a method, you ____________________ it from another method.
invoke
37
Access specifiers are also called access ____________________.
modifiers
38
When you think in an object-oriented manner, everything is a(n) ____________________.
object
39
A(n) ___________ is a number appended to a field, typically an ID number or account number.
check-digit
40
so that other classes can instantiate objects that belong to the class.
You declare constructors to be object
41
First line of a method
header
42
Combination of the method name and the number, types, and order of arguments
methods signature
43
Included within the method declaration parentheses
parameter type
44
Are called class methods
static methods
45
Variables in the method declaration that accept the values from the actual parameters
formal parameter
46
Used to return value back to the calling method
return statement
47
Data components of a class
instance variables
48
Application or class that instantiates objects of another prewritten class
class user
49
Variables you declare within a class, but outside of any method
data fields
50
a method that allows you to create objects from a class. You call the constructor by using the keyboard new, followed by the name of the class followed by any necessary parameter
Constructor
51
A method that allows you to create objects from a class. you call the constructor by using the keyword new followed by the name of the class, followed by any necessary parameter
Constructor
52
a method name followed by parenthesis Ex. calculate()
call
53
Value passed to a method
Argument
54
part of the method that receives data must the same type and in the same order as it is stated in the method declaration
Method parameter
55
Blueprint in which objects are created
class
56
initial requirement of the method. It is normally stated as part of the methods documentation.
Precondition
57
Creating a new class based on a previously defined class
Inheritance
58
Class that inherits from another class
Subclass
59
Has a name, parameter, and a return type, but no code in the body of the method.
Abstract Method
60
Class that contains one or more abstract methods. Abstract classes may not be instantiate, and require subclasses to provide implementation for the abstract methods
Abstract Class
61
Methods that stores a value in a field or in some other way changes the value of a field
Mutators
62
Does not return a value
Void Method
63
Cause a methods to end and sends a value back to the statement that called the methods
return
64
Two or more methods with the same name but different parameter types, order, and/ or number of parameters. When overloaded methods are called, the compiler decides which one to use based on the number, order, and type of parameter.
Method overloading
65
Methods that gets a value from a class's field, but does not change it
Accessors
66
Return the character at the specified index
char charAt(int index)
67
Returns number of characters in the string
int Length()
68
Return true if this string contains the same characters as str and false if it doesn't. Ignores lower and upper case
boolean equalIgnore Case(String str)
69
Returns position of the first character in the first occurrence of str in this string
int indexOf(String str)
70
Returns new string that is the same except all letters are in lowercase
String toLower Case{}
71
returns - --uppercase
String toUpperCase()
72
Adds the specified string to the end of original string
-String concat(String str)
73
A(n) __ is a program module that contains a series of statements that carry out a task.
Methods
74
the method__is the first line of a methods
Declaration
75
Executes first in application no matter where you physically place it within its class
Main Method
76
Data items you use in a call to a method are called
Arguments
77
____is the encapsulation of method details within a class
Implementation Hiding
78
A(n)___variable is known only within the boundaries of the methods
- Local
79
When a variable cease to exist st the end of a method, programmers say the variable____
-Goes out of scope
80
The arguments in a methods call are often referred to as____
Actual Parameter
81
A(n)____causes a value to be ssent from a called method back to the calling metho
return statement
82
an object is a(n) ___ of a class
-Member
83
Methods names that begins with "___" and "set" are very typical
84
Public classes are accessible by all objects, which means that public classes can be
Extend or / and used as a basis
85
Assigning ____ to a field means that no other classes can access the field's values
Private access
86
Methods used with objects intantiations are called _____methods
Instance
87
Methods that retrieve values are called _______methods
Accessors
88
A(n) unique identifier is most likely used as a(n) ____key in a database
Primary
89
A(n) _____methods is a methods that creates and initializes class objects
Constructor
90
For ease in locating class methods, many programmers stores them in ____ order.
Alphabetical
91
A(n) ___ constructor is one that requires no arguments
Default
92
You are ___required to write a constructor methods for a class
Never
93
to execute a method, you ____it from another methods
Invoke
94
Access specifiers are also called access___
Modifiers
95
When you think in an object-oriented manner, everything is a (n)____
Object
96
A(n) ____ is a number appended to a field, typically an ID number or account number
Check digit
97
So that other classes can instantiate that belong to the class
You declare constructors to be object
98
First line of method
Header
99
Combination of the methods name and the number, types, and order of arguments
Methods signature
100
included with the methods declaration parantheses
Parameter type
101
Are called class methods
Static methods
102
variables in the methods declaration that accept the values from the actual parameters
Formal statement
103
used to return value back to calling method
return statement
104
data components of a class
instance variable
105
application or class that instantiate objects of another prewitten class
class user
106
variables you declare within a class, but outside of any methods
data fields
107
a group of characters separated by spaces
token
108
preparing a disk file for reading
operating file
109
used to send characters to a text file
PrintWriter
110
data that is supplied to a method just before it starts running.
parameter
111
ArrayDemo.
112
3 Fundamental Features of OOP
1) encapsulation 2) inheritance 3) polymorphism
113
an object-oriented technique in which the internal details of an object are "hidden" in order to simplify their use and reuse
encapsulation
114
a relationship between two classes in which one class ( the subclass) inherits all of the properties and capabilities of another ( the superclass)
inheritance
115
declaring a variable to have one type while it refers to an object of a subclass of that type
polymorphism
116
a means of determining what aspects of a given problem can be viewed as objects in an eventual object-oriented design
object-oriented analysis
117
a software design method that models the characteristics of abstract or real objects using classes and objects.
object-oriented design
118
a programming technique that features objects, classes, encapsulation, interfaces, polymorphism, and inheritance.
object-oriented programming
119
degree to which responsibilities of a given component are a meaningful unit
cohesion
120
greater cohesion reflects better design; less coupling reflects better design.
cohesion vs coupling
121
degree to which one component must directly access the data of another component.
coupling
122
sets of responsibilities
roles
123
they are the same when a given role is always played by the same object type
roles vs. objects
124
3 Means of Object-Object Access
1) parameter passing 2) object declared in method 3) object is a member of another object through composition [subtype]
125
describes an inheritance relationship between two classes
is-a relationship
126
the relationship demonstrated by a class that contains another class
has-a relationship
127
implemented-in-terms-of relationship
uses-a relationship
128
known as "class variables", because there is only one unique value for all the objects of that same class
static members
129
special reference that refers to the object in which it is used
this
130
special reference that refers to the superclass of the object in which it is used
super
131
Determine whether a subclass is a subtype
Liskov Substitution Principle
132
no outside classes can use this data field (except descendant classes), defeats the purpose of OOP
protected access
133
type cast to the type of an ancestor class; usually done automatically
upcasting
134
type cast to the type of a descendant class; may cause runtime errors
downcasting
135
UML diagram that captures all actors (an individual or another system) and use cases involved with a system or product; Used to model user requirements
use case diagram
136
a visual representation of the relationships between classes
class diagram
137
represents real-world whole-part relationships | e.g., an engine is a part of a car
composition
138
represents a class as a collection or container of other classes
aggregation
139
used to show that some UML element or a set of elements requires, needs or depends on other model elements for specification or implementation
dependency
140
minimum and maximum number of occurrences of one object for a single occurrence of related object
multiplicity
141
signifies the role that a participating entity type plays in each relationship instance. In some cases the same entity type participates more than once in a relationship type in different roles.
role name
142
a type of diagram that shows objects participating in interactions and the messages exchanged between them.
sequence diagram
143
this pattern ensures you have at most one instance of a class in your application
singleton pattern
144
the design pattern that provides a way to access the elements of an aggregate object sequentially without exposing the underlying representation.
iterator pattern
145
the design pattern that translates one interface for a class into a compatible interface
adapter pattern
146
- simplifies the interface of a group of classes, - hides the complexity of one or more classes behind a clean, well-lit facade, - makes an interface simple. - provides a unified interface to a set of interfaces in a subsystem
facade pattern
147
1) Determines the requirements of a system 2) Focus on what needs to be done (not how) 3) Carried out by a team of analysts 4) End product is a conceptual model
Object-Oriented Analysis Stage
148
1) Major subsystems should be loosely coupled, allowing independence 2) Many-to-many relationships require an additional class 3) Avoid exposing details of business logic implementation to the user interface 4) Avoid exporting mutable objects 5) Avoid importing objects of an internal type in the system
5 Design Principles
149
aka "Single Dot Rule" | Long lists of method calls are attributed to bad design
Law of Demeter
150
Integer class is an example of Decorator pattern. (a) True (b) False
(a) True
151
In which of the following pattern an interface is responsible for creating a factory of related objects without explicitly specifying their classes? (a) Factory Pattern (b) Abstract Factory Pattern (c) Singleton Pattern
(b) Abstract Factory Pattern
152
Which of the following describes the Structural pattern correctly? (a) This type of patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator (b) This type of patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities. (c) This type of pattern are specifically concerned with communication between objects.
(b) This type of patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
153
Which of the following is the correct list of entities of MVC pattern? (a) Middle, Viewer, Controller (b) Model, View, Control (c) Model, Viewer, Control (d) Model, View, Controller
(d) Model, View, Controller
154
# Define a family of algorithms, encapsulate each one, and make them interchangeable. It lets the algorithm vary independently from clients that use it. (a) Decorator (b) Composite (c) Strategy
(c) Strategy
155
Which method must be defined by a class implementing the java.lang.Runnable interface? (a) public void start() (b) void notify() (c) void run() (d) none of these
(c) void run()
156
wait(), notify() & notifyAll() are methods of which class or interface? (a) Object (b) Thread class (c) Runnable interface (d) None
(a) Object
157
When start() method is called on thread it enters ______ state. (a) running (b) new (c) waiting (d) runnable
(d) runnable
158
What are the different ways of creating thread? (a) Extending Thread class. (b) Implementing Runnable interface (c) Using Thread Executor framework ( thread pool) (d) All of the above (e) None of the above
(d) All of the above
159
What is race condition in Java (a) Two threads try to execute earlier form sort of race. (b) Two or more threads can access shared data and they try to change it at the same time (c) Race condition doesn't allow two threads to access same resource
(b) Two or more threads can access shared data and they try to change it at the same time
160
JUnit tests can be run automatically, and they check their own results and provide immediate feedback. (a) True (b) False
(a) True
161
Which of the following annotation causes that Junit method run once after all tests have finished? (a) @BeforeClass (b) @AfterClass (c) @Test (d) @After
(b) @AfterClass
162
What is the base class of nearly all Swing classes? (a) Object (b) Component (c) JComponent (d) Swing
(c) JComponent
163
What is a container object in GUI programming? (a) A container is another name for an array or vector. (b) A container is any class that is made up of other classes. (c) A container is a primitive variable that contains the actual data. (d) A container is an object like a frame that has other GUI components placed inside of it.
(d) A container is an object like a frame that has other GUI components placed inside of it.
164
When you create a JFame object it is not automatically displayed. (a) True (b) False
(a) True
165
Which of the following are false about Collections and Collection? (a) Collections is a utility class (b) Collection is an interface to Set and List (c) Collections is a special type of collection which holds Set of collections (d) Both Collections and Collection entity belongs to java.util package.
(c) Collections is a special type of collection which holds Set of collections
166
Which of the following is false about collections in Java? (a) List, Map and Set are interfaces. (b) java.util is the default package for collection classes. (c) Collection interface is the base interface. (d) List, Map and Set are abstract classes
(d) List, Map and Set are abstract classes
167
What is it called when a program is written to respond to the button clicks, menu selections, and other actions of the user in whatever order the user does them? (a) Event-driven programming. (b) Action-driven programming. (c) User-driven programming. (d) Mouse-driven programming
(a) Event-driven programming.
168
What is the name for a method that responds to events? (a) A container method. (b) A listener method. (c) A snoop method. (d) An application method
(b) A listener method.
169
. Which of the following methods can be used to draw the outline of a square within a java.awt.Component object? 1. fillRect() 2. drawLine() 3. drawRect() 4. drawString() 5. drawPolygon() (a) 2 and 3 (b) 1,2, and 3 (c) 2,3, and 5 (d) 3,4, and 5.
(c) 2,3, and 5
170
A class is divided into which of these compartments? a. Name Compartment b. Attribute Compartment c. Operation Compartment d. All of the above
d. All of the above
171
What is multiplicity for an association? a. The multiplicity at the target class end of an association is the number of instances that can be associated with a single instance of source class b. The multiplicity at the target class end of an association is the number of instances that can be associated with a number instance of source class c. a) and b) d. None of the above
a. The multiplicity at the target class end of an association is the number of instances that can be associated with a single instance of source class
172
Which of these are the heuristics? a. Name classes, attributes, and roles with noun phrases b. Name operations and associations with verb phrases c. Stick to binary associations d. All of the above
d. All of the above
173
Use case descriptions consists of interaction among which of the following? a. Products b. Actors c. Products & Actors d. Usecases
c. Products & Actor
174
Use case description contents includes? a. Use case name and number b. Actors c. Stakeholder and needs d. All the above
d. All the above
175
Use case diagram and sequence diagram are considered as types of a. non-behavioral diagrams b. behavioral diagrams c. non structural diagrams d. structural diagrams
b. behavioral diagrams
176
Which of the following is NOT a tool that can be used for discovering class behaviors and responsibilities? a. CRC cards b. interface c. sequence diagram d. none of the above
b. interface
177
In which of the following relationships, does the whole have a responsibility for the part, and is usually shown with a filled-in diamond? a. Whole/part b. Composition c. Aggregation d. Association
b. Composition
178
Which diagram models the life cycle of a single object? a. Sequence diagram b. Use case diagram c. State machine diagram d. None of the above
c. State machine diagram
179
Indicate if the statement is true or false based on the UML diagram below: "This web service is used by any number of users" a. True b. False
a. True
180
Which of these can be used to fully abstract a class from its implementation? (a) Objects (b) Packages (c) Interfaces (d) None of the Mentioned.
(c) Interfaces
181
In Java, a class may have _superclass(es) and implement ___interface(s) (a) only one / only one (b) multiple / only one (c) only one / multiple (d) multiple / multiple
(c) only one / multiple
182
What is the correct syntax for defining a new class Parakeet based on the superclass Bird? (a) class Parakeet is-a Bird{ } (b) class Bird defines Parakeet{ } (c) class Bird has-a Parakeet{ } (d) class Parakeet extends Bird{ }
(d) class Parakeet extends Bird{ }
183
The private members of a superclass can be accessed by a subclass. (a) True (b) False
(b) False
184
You can instantiate an object of a subclass of an abstract class, but only if the subclass gives the definitions of all the abstract methods of the superclass. (a) True (b) False
(a) True
185
The method toString() is a public member of the class ____. (a) Object (b) String (c) Writer (d) Output
(a) Object
186
An abstract method ____. (a) is any method in the abstract class (b) cannot be inherited (c) has no body (d) is found in a subclass and overrides methods in a superclass using the reserved word abstract
(c) has no bod
187
If class Dog has a subclass Retriever, which of the following is true? (a) Because of single inheritance, Dog can have no other subclasses. (b) Because of single inheritance, Retriever can extend no other class except Dog. (c) The relationship between these classes implies that Dog "is-a" Retriever. (d) The relationship between these classes implies that Retriever "has-a" Dog.
(b) Because of single inheritance, Retriever can extend no other class except Dog.
188
Which of the following statement about Java is FALSE? (a) All objects are dynamically allocated. (b) Every function (method) must belong to a class. (c) It uses garbage collection to deallocate dynamically allocated objects. (d) ArrayList elements can be primitive types or objects.
(d) ArrayList elements can be primitive types or objects.
189
In Java, you can automatically make a reference variable of a subclass type point to an object of its superclass. (a) True (b) False
(b) False
190
Reuse of code (e.g. Visual Basic, JavaBean)
Software Components
191
Reuse of "plug-in" code (e.g. Java Swing)
Frameworks
192
Reuse of Design
Design Paterns
193
is a sequence of values of the same type. They can hold both primitives and objects.
array
194
What field returns the number of elements in an array?
The length field. It is an instance variable of the array.
194
Syntax for array element access
arrayReference[index] | Ex. data[2]
195
Syntax for initializing an array
typeName[] arrayReference = new typeName[length] | Ex. double[] data = new double[10];
196
How do you access the last index of an array?
arrayReference[length - 1]
197
Initialize an integer array named primes with five values.
int[] primes = new int[] { 2, 3, 5, 7, 11 };
198
using a method on an uninitialized object will cause a ___________. Unchecked.
NullPointerException
199
Each object is a distinct individual
Identity
200
has a various properties, which might change
State
201
It can do thing and can have things done to is
Behavior
202
A description of a kind of object
Class
203
Creating an object
Instantiation
204
a characteristic of a class that is not shared by its objects
Static
205
the method that belongs to a class definition
Static Method
206
this means that after construction, they cannot be altered
String Objects are immutable
207
Is constructed out a block of main memory and hence has a unique location
Object
208
Is constructed out a block of main memory and hence has a unique location
Object
209
Describe the location in memory of a particular object
Object reference
210
Does not contain the actual object, just how to find it.
Reference Variable
211
Is the correct term for objects that are not referred to by any referred to by any reference variable
Garbage
212
Reclaims the last objects so that the memory they are made of can be used again.
Garbage collector
213
are sometimes called variable
field
214
Is a request to run a method of an object
Method call
215
Used to specify which object, and what method of that object run
Dot notation
216
the programmer ask for values to be converted with a type cast
Explicitly
217
If the compiler can make the conversion without loss of information, or with only a small loss of precision, it will automatically do so.
Implicitly
217
If the compiler can make the conversion without loss of information, or with only a small loss of precision, it will automatically do so.
Implicitly
218
Means that some of the less significant digit may become zeros, but the most important digits and the size of the size of the number will remain
Less of precision
219
Are very useful and are frequently used
String Object
220
Is a special value that means "no object"
Null
221
A string object that contains no characters is still an object
Empty String
222
Sometimes immutable objects are called
write-once
223
the concat method performs
String concatenation
224
When an operator such as + changes meaning depending on its argument, it is said to be
Overloaded
225
the stage where the compiled program is running
Run Time
226
used to hand back a value to the caller
Return statement
227
is the type of value that method hands back to the caller of the method.
Return type
228
is automatically supplied by the java compiler
Default Constructor
229
is a list of values and their types
Parameter list
230
class that contains main()
Driver
231
is a variable that holds part of the state of an object
Instance Variable
232
Variable that are object(each instance of a class) has a part of itself
Instance Variable
233
is the type of one item of data that will be handed to the constructor
Data Type
234
Is a name that is used for that item of data
Parameter Name
235
to show when an identifier refers to an objects instance variable
This
236
is an identifier picked by the programmer
Method name
237
is the method name and parameter list
Signiture of a method
238
a method that changes the state of an object
Mutator / setter
239
a method that returns a value from an instance variable
Access method/ getter
240
Decide what checking account object do and what data they hold
requirement analysis
241
the compiler puts in a toString() method even if you did not write
Inheriance
242
recall that there can be more than one reference to a given object. Each reference is called
alias
243
using a method on an uninitialized object will cause a ___________. Unchecked.
NullPointerException
244
situation when use to exceptions.
Accessing Data Files, User input
245
These exceptions are always Unchecked
Runtime Exceptions
246
Class is in the java.lang package
Throwable
247
Class extends the Object class
Throwable
248
Class implements the Serializable Inteface
Throwable
249
Used for launching an exception.
throw new
250
User has entered invalid data
Exceptions Best Practice
251
A file that needs to be opened cannot be found
Exceptions Best Practice
252
Network connection has been lost in the middle of communication.
Exceptions Best Practice
253
JVM has run out of memory
Exceptions Best Practice
254
Class includes the bytesTransferred filed that provides information on how many bytes were transferred successfully before the interruption occurred
InterruptedIOException
255
This classes can be thrown
Exception()
256
This classes can be thrown
Throwable()
257
This classes can be thrown
Error()
258
This classes can be thrown
RuntimeException()
259
Has the fewest subclasses when compared to Exception and RuntimeException Classes.
Error Class
260
SuperClass of Error Exceptions, Subclass of VirtualMachineError. Constructors accept String argument or no argument.
Internal Error
261
SuperClass of Error Exceptions, Subclass of VirtualMachineError. Constructors accept String argument or no argument.
OutOfMemoryError
262
SuperClass of Error Exceptions, Subclass of VirtualMachineError. Constructors accept String argument or no argument.
StackOverflowError
263
SuperClass of Error Exceptions, Subclass of VirtualMachineError. Constructors accept String argument or no argument.
UnknownError
264
This class does not have a no argument constructor
IIOException
265
Used for logging unexpected behavior
Java Exception Mechanism
266
Used to determine what to do when something unexpected happens.
Java Exception Mechanism
267
Standard Java exception class
java.lang.SecurtiyException
268
Standard Java exception class
java.io.FileNotFoundException
269
Improves code because error handling code is clearly separated from main program logic.
Java Exception Mechanism
270
Allows creation of new exceptions that are custom to a particular application domain.
Java Exception Mechanism
270
Allows creation of new exceptions that are custom to a particular application domain.
Java Exception Mechanism
271
Can declare that it throws a checked exception
Main Method Exception
272
Exception can throw instances of any subclass of that exception class.
Exception Classes
273
Can not be reached in the catch block.
try block variables
274
IllegalStateException
Application
275
IllegalArgumentException
Application
276
ClassCastException NullPointerException SecurityException
JVM
277
What is the process of defining more than one method in a class differentiated by parameters? a) Function overriding b) Function overloading c) Function doubling d) None of these
b
278
Which of these can be used to diffrentiate two or more methods having same name? a) Parameters data type b) Number of parameters c) Return type of method d) All of the mentioned
d
279
What is the output of this program? ``` class box { int width; int height; int length; int volume; void volume(int height, int length, int width) { volume = width height length; } } class Prameterized_method{ public static void main(String args[]) { box obj = new box(); obj.height = 1; obj.length = 5; obj.width = 5; obj.volume(3, 2, 1); System.out.println(obj.volume); } } a) 0 b) 1 c) 6 d) 25 ```
c
280
Which of these data tupe can be used for a method having a return statement in it? a) void b) int c) float d) All of the mentioned
d
281
What is the output of this program? ``` class equality { int x; int y; boolean isequal(){ return(x == y); } } class Output { public static void main(String args[]) { equality obj = new equality(); obj.x = 5; obj.y = 5; System.out.println(obj.isequal); } } a) false b) true c) 0 d) 1 ```
b
282
What is the output of this program? ``` class box { int width; int height; int length; int volume; void volume() { volume = width height length; } void volume(int x) { volume = x; } } class Output { public static void main(String args[]) { box obj = new box(); obj.height = 1; obj.length = 5; obj.width = 5; obj.volume(5); System.out.println(obj.volume); } } a) 0 b) 5 c) 25 d) 26 ```
b
283
``` What is the output of this program? class Output { static void main(String args[]) { int x , y = 1; x = 10; if(x != 10 && x / 0 == 0) System.out.println(y); else System.out.println(++y); } } a) 1 b) 2 c) Runtime Error d) Compilation Error ```
d
284
What is the output of this program? ``` class area { int width; int length; int volume; area() { width = 5; length = 6; } void volume() { volume = width height length; } } class cons_method { public static void main(String args[]) { area obj = new area(); obj.volume(); System.out.println(obj.volume); } } a) 0 b) 1 c) 25 d) 30 ```
d
285
When does Exceptions in Java arises in code sequence? a) Run Time b) Compilation Time c) Can Occur Any Time d) None of the mentioned
a
286
Which of these keywords is not a part of exception handling? a) try b) finally c) thrown d) catch
c
287
Which of these keywords must be used to monitor for exceptions? a) try b) finally c) throw d) catch
a
288
Which of these keywords must be used to handle the exception thrown by try block in some rational manner? a) try b) finally c) throw d) catch
d
289
Which of these keywords is used to manually throw an exception? a) try b) finally c) throw d) catch
c
290
What is the output of this program? ``` class exception_handling { public static void main(String args[]) { try { System.out.print("Hello" + " " + 1 / 0); } catch(ArithmeticException e) { System.out.print("World"); } } } a) Hello b) World c) HelloWorld d) Hello World ```
b
291
What is the output of this program? ``` class exception_handling { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } } a) A b) B c) Compilation Error d) Runtime Error ```
b
292
``` } } a) Hello b) World c) HelloWorld d) Hello World b ``` What is the output of this program? ``` class exception_handling { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } } a) A b) B c) Compilation Error d) Runtime Error b ``` What is the output of this program? ``` class exception_handling { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } finally { System.out.print("C"); } } } a) A b) B c) AC d) BC ```
d
292
``` } } a) Hello b) World c) HelloWorld d) Hello World b ``` What is the output of this program? ``` class exception_handling { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } } a) A b) B c) Compilation Error d) Runtime Error b ``` What is the output of this program? ``` class exception_handling { public static void main(String args[]) { try { int a, b; b = 0; a = 5 / b; System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } finally { System.out.print("C"); } } } a) A b) B c) AC d) BC ```
d
293
``` What is the output of this program? class exception_handling { public static void main(String args[]) { try { int i, sum; sum = 10; for (i = -1; i < 3 ;++i) sum = (sum / i); } catch(ArithmeticException e) { System.out.print("0"); } System.out.print(sum); } } a) 0 b) 05 c) Compilation Error d) Runtime Error ```
c
294
What is the output of this program? ``` class exception_handling { public static void main(String args[]) { try { int i, sum; sum = 10; for (i = -1; i < 3 ;++i) { sum = (sum / i); System.out.print(i); } } catch(ArithmeticException e) { System.out.print("0"); } } } a) -1 b) 0 c) -10 d) -101 ```
c
295
Which of these is a super class of all exceptional type classes? a) String b) RuntimeExceptions c) Throwable d) Cachable
c
296
Which of these class is related to all the exceptions that can be caught by using catch? a) Error b) Exception c) RuntimeExecption d) All of the mentioned
b
297
Recu____ the technique of making a function call itself. This technique provides a way to break complicated problems down into simple problems which are easier to solve. Recu____ may be a bit difficult to understand. The best way to figure out how it works is to experiment with it
Java recursion
298
Adding two numbers together is easy to do, but adding a range of numbers is more complicated. In the following example, recursion is used to add a range of numbers together by breaking it down into the simple task of adding two numbers: Use recursion to add all of the numbers up to 10. ``` public class MyClass { public static void main(String[] args) { int result = sum(10); System.out.println(result); } public static int sum(int k) { if (k > 0) { return k + sum(k - 1); } else { return 0; } } } ```
Recursion continued
299
Example Explained When the sum() function is called, it adds parameter k to the sum of all numbers smaller than k and returns the result. When k becomes 0, the function just returns 0. When running, the program follows these steps: 10 + sum(9) 10 + ( 9 + sum(8) ) 10 + ( 9 + ( 8 + sum(7) ) ) ... 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + sum(0) 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 Since the function does not call itself when k is 0, the program stops there and returns the result.
Recursion continued part 2
300
Just as loops can run into the problem of infinite looping, recursive functions can run into the problem of infinite recursion. Infinite recursion is when the function never stops calling itself. Every recursive function should have a halting condition, which is the condition where the function stops calling itself. In the previous example, the halting condition is when the parameter k becomes 0. It is helpful to see a variety of different examples to better understand the concept. In this example, the function adds a range of numbers between a start and an end. The halting condition for this recursive function is when end is not greater than start:
Halting condition
301
Use recursion to add all of the numbers between 5 to 10. ``` public class MyClass { public static void main(String[] args) { int result = sum(5, 10); System.out.println(result); } public static int sum(int start, int end) { if (end > start) { return end + sum(start, end - 1); } else { return end; } } } ```
Halting condition continued
302
the ___ package contains frequently used classes and is implicity imported into java program.
java.lang
303
defienes the circumstances under which a class can be accessed and the other classes that have the right to use a class
access specifier
304
an indefinite loop
event - controlled
305
requires three expressions separated with a question mark and a colon
conditional operator
306
describes the feature of language that allows the same word to be interpreted correctly in different situations based on the content
polymorphism
307
another name for a nonstatic member class
inner class
308
statement is the decision structure you use when you need to take other of the two possible course of action
dual alternative if
309
programs that are embedded in a web page
java applets
310
is the type to which all operands in an expression are converted so that they are compatible with each other
unifying type
311
refers to the order in which values are used with operators
associativity
312
are also called modules, methods, function, and subroutines
producers
313
the reference to an object that is passed to any object's nonstatic method
this reference
314
you can use ___ arguments to initialize field values, but you can also use arguments for any other purpose
constructor
315
is the process of ensuring that a value falls within a specified range
validating data
316
loop_____ is the technique of combining two loops into one
fusion
317
the order of the conditional expressions in the following is most important within a(n) ____ loop
nested
318
a(n)____ loop is an indefinite loop in which the number of execution is determined by user actions
event - controlled
319
a(n) ____ loop is one that performs no actions other than looping
do-nothing
320
one execution of any loop
iteration
321
the modulus operator (%) is a _____operator
Binary
322
a value that stops the loop
sentinel
323
a loop controlled by the user is a type of _____loop
incrementing
324
is the first input statement prior to a loop that will execute a subsequent input statement for the same variable
Priming read
325
Before entering a loop, the first input statement, or ___, is retrieved
Priming read
326
the prefix that is a ____operator
Unary
327
the process of repeating increasing a value by some amount
Accumulating
328
is used for mean in java
final
329
is used as a return value to flag an error
ERRORFLAG
330
is data that is supplied to a method just before it starts running.
Parameter
331
when they have the same name but different types or numbers of parameters. The compiler will inspect the parameters of a method call and pick the method that best matches the parameter list.
overloaded methods
332
Do you think that this method should print out an error message when it detects an error?
yes
333
what types of data can arrays hold in their cells?
Any type of data at all:
334
What is the name of the parameter passing mechanism that Java uses?
Call by Value.
335
the programmer ask for values to be converted with a type cast
Explicitly
336
if the compiler can make the conversion without less of information or with only a small less of precision, it will automatically do so.
Implicitly
337
means that some of the less significant digit may become zeros but the most important digits and the size of the size of the number will remain
Less precision
338
is a name that is used for that item of data
parameter name
339
is the method name and parameter list
signiture of a method
340
a method that changes the state of an object
Mutator method
341
a method that changes the state of an object
Mutator/Setter
342
a method that returns a value from an instance variable
Access method / Getter
343
when an object's instance variables are visible only to the subject's own methods.
Encapsulation
344
can be used only by the other methods of the objects
Private Method
345
a group of related classes
Package
345
a group of related classes
Package
346
is a value that is sent to a method when it is called
Parameter
347
is a name used for a class a variable or a parameter
Identifier
348
are bound to an actual value only as long as their method is active
Formal Parameter
349
the section of source code that can see the parameter
Scope of a formal parameter
350
is a variable that is declared inside of the body of a method
Local Variable
351
short from where it is declared and ends at the end of the body of a method
Scope of local variable
352
the identifier used in a method to sand for the value that will be passed into the method by a caller
Formal Parameter
353
the actual value that is passed
Actual Parameter
354
the type of parameter passing that java uses
call by value
355
is part of an object of the type describe by the class
Instance Variable
356
a variable whos scope extends over the entire program
Global Variable
357
is an object that is used to share a list of values
arrays
358
an array is made out of a contiguous block of memory that is divided into a number of
cell
359
an expression such as data[3]
Subscripted variable
360
a java program is running, each time an array index is used it is checked to be sure that it is ok
Bounds Checking
361
The words on the command line after the name of the program
command line arguments
362
an array that uses a single substription
One dimensional array
363
requires two indexes to access values
two dimensional array
364
a systematic procedure used to compute something
Algorithm
365
How can a program tell how many command line arguments it has been given?
Use args.length
366
Are the data in a list always processed in order?
No.
367
Can the linear search algorithm be used on a partially full array?
Yes, of course. You need to watch out for nulls, though.
368
used to postpone the handling of a checked exception
throws
369
is used to invoke an exception explicitly.
throw
370
Which exceptions needs to be declared
only checked exception
371
Which of these class is related to all the exceptions that cannot be caught? a) Error b) Exception c) RuntimeExecption d) All of the mentioned
a) Error
372
Which of these handles the exception when no catch is used? a) Default handler b) finally c) throw handler d) Java run time system
a) Default handler
373
Which of these keywords is used to generate an exception explicitly? a) try b) finally c) throw d) catch
c) throw
374
Which of these class is related to all the exceptions that are explicitly thrown? a) Error b) Exception c) Throwable d) Throw
c) Throwable
374
Which of these class is related to all the exceptions that are explicitly thrown? a) Error b) Exception c) Throwable d) Throw
c) Throwable
375
Which of these class is related to all the exceptions that are explicitly thrown? a) Error b) Exception c) Throwable d) Throw
c) Throwable
376
Which of these operator is used to generate an instance of an exception than can be thrown by using throw? a) new b) malloc c) alloc d) thrown
a) new
377
Which of these handles the exception when no catch is used? a) Default handler b) finally c) throw handler d) Java run time system
a) Default handler
378
Which of these keywords is used to by the calling function to guard against the exception that is thrown by called function? a) try b) throw c) throws d) catch
c) throws
379
a sequence of data | - two kinds of Streams = InPutStream, OutPutStream
Stream
380
is used to read data from a source.
InPutStream
381
is used for writing data to a destination.
OutPutStream
382
perform input and output for 16-bit unicode - most frequently used classes are, FileReader and FileWriter. - Though internally FileReader uses FileInputStream and FileWriter uses FileOutputStream but here the major difference is that FileReader reads two bytes at a time and FileWriter writes two bytes at a time.
Character Streams
383
How to find the number of elements in: a) an Array b) an ArrayList c) a String
a) .length b) .size() c) .length()
384
stores a reference to the array. Copying the variable yields a second reference to the same array.
array variable
385
Syntax of copying an array.
double[] prices = (double[]) data.clone();
386
This is used to output the error data produced by the user's program and usually a computer screen is used for standard error stream and represented as System.err.
Standard Streams : Standard Error
387
Two different arrays that should be combined into one array containing objects.
parallel arrays