Chapter 5 Flashcards
___ in a program can represent real-world things or abstractions
Objects
An _____ of a class is an object
instance
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.
True
the data items and the methods are sometimes called ___ because they belong to the object
members
What are these called?
public String name;
public String breed;
public int age;
Instance Variables
Why do we need the word new ?
we use to create objects of a class.
What is nextInt is?
a method
Methods that some preform action other than returning a value are called
void methods
What is the formula to call a method?
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( );
What is a Scanner?
Class
True or False, Is it true that main is a void method?
true
True or False. It is preferred to use one return statement in a method.
True
Does Java have functions?
No, it doesnt
Can a void method contain a return statement?
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;
True or False, within a class definition, this is a name for the receiving object
True
What is “ this “ can be used for?
you can use the keyword this as a name for the object receiving the method call
Variables are confined to a method definition
local variables
Variables are confined to an object of a class
instance variables
A type of variables that Java does not have, but other programmes have
global variables.
When you declare a variable within a compound statement, the compound statement is usually called
block
The things that serve as blanks in methods are called
parameters
Java passes arguments to a method using
call-by-value
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.
True
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
True
Designing a method so that it can be used without any need the fine detail of the code is called
Information Hiding (also called “abstraction.”) .. or encapsulation groups instance variables and methods into a class
A method’s _____ comment states the conditions that must be true before the method is invoked.
precondition
The keywords public and private are examples of ____
access modifiers
True or False, private methods are called only within their own class?
True
True or False, Public instance variables can lead to the corruption of an object’s data?
True
True or False, Private instance variables enable the class to restrict how they are accessed or changed
True
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
getter
What do getters do?
is simply a method that allows you to look at data contained in an instance variable.
a method that allows you to change the data stored in private instance variables called?
setters
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
True
What is an ADT?
is short for abstract data type.
comments result in neat HTML documentation called:
javadoc
What does UML in UML Class Diagrams stands for?
Unified Modeling Language
What does UML do?
UML is useful for designing and building a class
Variables of a class type named?
objects
Some programmers refer to the parameter mechanism for parameters of a class type as ______ parameter passing
call-by-reference
What is Differences Between Primitive-Type and Class-Type Parameters?
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.