Chapter 5 Flashcards

1
Q

___ in a program can represent real-world things or abstractions

A

Objects

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

An _____ of a class is an object

A

instance

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

True or False, The class definition has no data—that is, no numbers and no string. The individual objects have the data, but the class specifies what kind of data they have. The class also specifies what actions the objects can take and how they accomplish those actions.

A

True

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

the data items and the methods are sometimes called ___ because they belong to the object

A

members

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

What are these called?
public String name;
public String breed;
public int age;

A

Instance Variables

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

Why do we need the word new ?

A

we use to create objects of a class.

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

What is nextInt is?

A

a method

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

Methods that some preform action other than returning a value are called

A

void methods

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

What is the formula to call a method?

A

You invoke a method by writing the name of the receiving object followed by a dot, the name of the method, and finally a set of parentheses that can contain arguments providing information for the method. Object.Method( );

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

What is a Scanner?

A

Class

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

True or False, Is it true that main is a void method?

A

true

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

True or False. It is preferred to use one return statement in a method.

A

True

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

Does Java have functions?

A

No, it doesnt

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

Can a void method contain a return statement?

A

Since a void method returns no value, it typically does not have any return statement. However, you can write a return statement within a void method without an accompanying expression, as follows:

return;

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

True or False, within a class definition, this is a name for the receiving object

A

True

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

What is “ this “ can be used for?

A

you can use the keyword this as a name for the object receiving the method call

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

Variables are confined to a method definition

A

local variables

18
Q

Variables are confined to an object of a class

A

instance variables

19
Q

A type of variables that Java does not have, but other programmes have

A

global variables.

20
Q

When you declare a variable within a compound statement, the compound statement is usually called

A

block

21
Q

The things that serve as blanks in methods are called

A

parameters

22
Q

Java passes arguments to a method using

A

call-by-value

23
Q

True or False, In Java, you can choose the name of a method’s formal parameter without any concern that this name will be the same as an identifier used in some other method. Formal parameters are really local variables, and so their meanings are confined to their respective method definitions.

A

True

24
Q

True or False. An argument in a method invocation that is of any of these types will automatically be converted to any of the types that appear to its right if that is needed to match a formal parameter:
byte→short→int→long→float→double

A

True

25
Q

Designing a method so that it can be used without any need the fine detail of the code is called

A

Information Hiding (also called “abstraction.”) .. or encapsulation groups instance variables and methods into a class

26
Q

A method’s _____ comment states the conditions that must be true before the method is invoked.

A

precondition

27
Q

The keywords public and private are examples of ____

A

access modifiers

28
Q

True or False, private methods are called only within their own class?

A

True

29
Q

True or False, Public instance variables can lead to the corruption of an object’s data?

A

True

30
Q

True or False, Private instance variables enable the class to restrict how they are accessed or changed

A

True

31
Q

Making all instance variables private does control access an instance to you have a legitimate reason to access an instance variable? For these cases, you should provide accessor methods called

A

getter

32
Q

What do getters do?

A

is simply a method that allows you to look at data contained in an instance variable.

33
Q

a method that allows you to change the data stored in private instance variables called?

A

setters

34
Q

True or False, A method body can contain an invocation of another method. The situation for this sort of method call is exactly the same as it would be if the method call had occurred in the main method of a program

A

True

35
Q

What is an ADT?

A

is short for abstract data type.

36
Q

comments result in neat HTML documentation called:

A

javadoc

37
Q

What does UML in UML Class Diagrams stands for?

A

Unified Modeling Language

38
Q

What does UML do?

A

UML is useful for designing and building a class

39
Q

Variables of a class type named?

A

objects

40
Q

Some programmers refer to the parameter mechanism for parameters of a class type as ______ parameter passing

A

call-by-reference

41
Q

What is Differences Between Primitive-Type and Class-Type Parameters?

A

A method cannot change the value of an argument of a primitive type that is passed to it. In addition, a method cannot replace an object passed to it as an argument with another object. On the other hand, a method can change the values of the instance variables of an argument of a class type.