Ch 3 & 4 Quiz 3 Flashcards

1
Q

T/F: in Java, a class can have one method with the same name, to avoid confusing the compiler.

A

F: A class May contain more than one constructor, or more than one method of the same name, as long as each has a distinctive set of parameter types.

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

What type can x be?


x someVariable;
x = “15.02”;

A

String

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

T/F: based on the code, you can conclude that type x is of a primitive type.


x someVariable;
x.doSomething();

A

F: the primitive types in Java are the non-object types. Types such as int, boolean, char, double, and long are the most common prim types. Prim types have no methods.

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

Breakpoint

A

A flag attached to a line of source code that will stop the execution of a method at that point when it is reached. It is represented in BlueJ editor as a small stop sign.

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

Classes that requires a second type to be specified as parameters are called?

A

Generic classes- in contrast to other classes do not define a single type in Java, but potentially many types.

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

Several objects are created in this code, which of them is considered an Anonymous object?

Public village()
{
smurf reader = new Smurf(); //#1
String name = new Smurf().getFirstName(); //#2
int age = new Smurf().getAge(); //#3
}

A

-2 & 3
-Anon object- object created with no name
- #1 has a variable that will point the created objects, so we can refer to this object later
- #2 & 3 has variables to remember the values returned from the methods called on the anon object. These 2 will only remember the values given to them, not the object that generated them.

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

Question 15

A

Practice question 15

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

Question 16

A

Work on question 16

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

Question 21

A

Practice question 21

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