Deck 4: Defining Classes I

ملء الشاشة (f)
exit full mode
سؤال
An object of class A is an instance of class A.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The new operator:

A)allocates memory
B)is used to create an object of a class
C)associates an object with a variable that names it.
D)All of the above.
سؤال
A set method is:

A)an accessor method
B)a mutator method
C)a recursive method
D)none of the above
سؤال
An invocation of a method that returns a value can be used as an expression any place that a value of the Type_Returned can be used.
سؤال
The Java language supports global variables.
سؤال
A variable whose meaning is confined to an object of a class is called:

A)instance variable
B)local variable
C)global variable
D)none of the above
سؤال
A method that performs some action other than returning a value is called a __________ method.

A)null
B)void
C)public
D)private
سؤال
A _________ states what is assumed to be true when the method is called.

A)prescript
B)postscript
C)precondition
D)postcondition
سؤال
In Java,call-by-value is only used with:

A)objects
B)primitive types
C)this
D)all of the above
سؤال
The name of a method and the list of ________ types in the heading of the method definition is called the method signature.

A)parameter
B)argument
C)return
D)primitive
سؤال
Accessor methods:

A)return something equivalent to the value of an instance variable.
B)promotes abstraction
C)both A and B
D)none of the above
سؤال
Java has a way of officially hiding details of a class definition.To hide details,you mark them as _________.

A)public
B)protected
C)private
D)all of the above
سؤال
A program whose only task is to test a method is called a:

A)driver program
B)stub
C)bottom-up test
D)recursive method
سؤال
Two methods that are expected to be in all Java classes are:

A)getName and setName
B)toString and equals
C)compareTo and charAt
D)toLowerCase and toUpperCase
سؤال
When the parameters in a method have the same as instance variables you can differentiate them by using the _____ parameter.

A)String
B)hidden
C)default
D)this
سؤال
In Java,a block is delimited by:

A))
B)/* */
C)" "
D){ }
سؤال
The body of a method that returns a value must contain at least one _________ statement.

A)void
B)invocation
C)thows
D)return
سؤال
A more eloquent approach in implementing mutator methods is to return a ________ value.

A)int
B)char
C)boolean
D)double
سؤال
The parameter this refers to

A)instance variables
B)local variables
C)global variables
D)the calling object
سؤال
A variable whose meaning is confined to a method definition is called an/a

A)instance variable
B)local variable
C)global variable
D)none of the above
سؤال
What is the purpose of the new operator?
سؤال
It is considered good programming practice to validate a value passed to a mutator method before setting the instance variable.
سؤال
When you give a command to run a Java program,the runtime system invokes the class constructor.
سؤال
Java supports operator overloading.
سؤال
Inside a Java method definition,you can use the keyword this as a name for the calling object.
سؤال
Write a method called power the computes x< sup >n< /sup > where x and n and positive integers.The method has two integer parameters and returns a value of type long.
سؤال
Define the terms arguments and parameters.How are they different?
سؤال
Create a class named Appointment that contains instance variables startTime,endTime,dayOfWeek valid values are Sunday through Saturday),and a date which consists of a month,day and year.All times should be in military time,therefore it is appropriate to use integers to represent the time.Create the appropriate accessor and mutator methods.
سؤال
Write a Java method that returns the value of PI,where PI = 3.1415926535.
سؤال
Boolean expressions may be used to control if-else or while statements.
سؤال
Discuss a situation in which it is appropriate to use the this parameter.
سؤال
Write a method called Greeting that displays a personalized greeting given a first name.
سؤال
The modifier private means that an instance variable can be accessed by name outside of the class definition.
سؤال
In a method invocation,there must be exactly the same number of arguments in parentheses as there are formal parameters in the method definition heading.
سؤال
Only the default constructor has the this parameter.
سؤال
Write a Java method that prints the phrase "Five purple people eaters were seen munching Martians".
سؤال
Write a method called isEqual that returns a Boolean value.The method compares two integers for equality.
سؤال
Method overloading is when two or more methods of the same class have the same name but differ in number or types of parameters.
سؤال
Discuss the public and private modifiers in context of methods and instance variables.
سؤال
Mutator methods can return integer values indicating if the change of the instance variable was a success.
سؤال
Write preconditions and postconditions for the power method you wrote in question #4.
سؤال
Discuss the importance of accessor and mutator methods and how they apply to the abstraction concept.
سؤال
Write a Java class that represents a Student with instance variables name,id,and gpa.Include constructors,accessor,mutator and any facilitator methods you may need.
سؤال
Add two constructors to the Appointment class created in question #9.Include a default constructor and a constructor to initialize an Appointment to suitable arguments.
سؤال
Write a driver program to test your Student class created in question #14.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/45
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Defining Classes I
1
An object of class A is an instance of class A.
True
2
The new operator:

A)allocates memory
B)is used to create an object of a class
C)associates an object with a variable that names it.
D)All of the above.
D
3
A set method is:

A)an accessor method
B)a mutator method
C)a recursive method
D)none of the above
B
4
An invocation of a method that returns a value can be used as an expression any place that a value of the Type_Returned can be used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
5
The Java language supports global variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
6
A variable whose meaning is confined to an object of a class is called:

A)instance variable
B)local variable
C)global variable
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
7
A method that performs some action other than returning a value is called a __________ method.

A)null
B)void
C)public
D)private
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
8
A _________ states what is assumed to be true when the method is called.

A)prescript
B)postscript
C)precondition
D)postcondition
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
9
In Java,call-by-value is only used with:

A)objects
B)primitive types
C)this
D)all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
10
The name of a method and the list of ________ types in the heading of the method definition is called the method signature.

A)parameter
B)argument
C)return
D)primitive
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
11
Accessor methods:

A)return something equivalent to the value of an instance variable.
B)promotes abstraction
C)both A and B
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
12
Java has a way of officially hiding details of a class definition.To hide details,you mark them as _________.

A)public
B)protected
C)private
D)all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
13
A program whose only task is to test a method is called a:

A)driver program
B)stub
C)bottom-up test
D)recursive method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
14
Two methods that are expected to be in all Java classes are:

A)getName and setName
B)toString and equals
C)compareTo and charAt
D)toLowerCase and toUpperCase
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
15
When the parameters in a method have the same as instance variables you can differentiate them by using the _____ parameter.

A)String
B)hidden
C)default
D)this
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
16
In Java,a block is delimited by:

A))
B)/* */
C)" "
D){ }
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
17
The body of a method that returns a value must contain at least one _________ statement.

A)void
B)invocation
C)thows
D)return
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
18
A more eloquent approach in implementing mutator methods is to return a ________ value.

A)int
B)char
C)boolean
D)double
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
19
The parameter this refers to

A)instance variables
B)local variables
C)global variables
D)the calling object
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
20
A variable whose meaning is confined to a method definition is called an/a

A)instance variable
B)local variable
C)global variable
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
21
What is the purpose of the new operator?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
22
It is considered good programming practice to validate a value passed to a mutator method before setting the instance variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
23
When you give a command to run a Java program,the runtime system invokes the class constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
24
Java supports operator overloading.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
25
Inside a Java method definition,you can use the keyword this as a name for the calling object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
26
Write a method called power the computes x< sup >n< /sup > where x and n and positive integers.The method has two integer parameters and returns a value of type long.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
27
Define the terms arguments and parameters.How are they different?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
28
Create a class named Appointment that contains instance variables startTime,endTime,dayOfWeek valid values are Sunday through Saturday),and a date which consists of a month,day and year.All times should be in military time,therefore it is appropriate to use integers to represent the time.Create the appropriate accessor and mutator methods.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
29
Write a Java method that returns the value of PI,where PI = 3.1415926535.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
30
Boolean expressions may be used to control if-else or while statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
31
Discuss a situation in which it is appropriate to use the this parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
32
Write a method called Greeting that displays a personalized greeting given a first name.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
33
The modifier private means that an instance variable can be accessed by name outside of the class definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
34
In a method invocation,there must be exactly the same number of arguments in parentheses as there are formal parameters in the method definition heading.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
35
Only the default constructor has the this parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
36
Write a Java method that prints the phrase "Five purple people eaters were seen munching Martians".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
37
Write a method called isEqual that returns a Boolean value.The method compares two integers for equality.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
38
Method overloading is when two or more methods of the same class have the same name but differ in number or types of parameters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
39
Discuss the public and private modifiers in context of methods and instance variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
40
Mutator methods can return integer values indicating if the change of the instance variable was a success.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
41
Write preconditions and postconditions for the power method you wrote in question #4.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
42
Discuss the importance of accessor and mutator methods and how they apply to the abstraction concept.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
43
Write a Java class that represents a Student with instance variables name,id,and gpa.Include constructors,accessor,mutator and any facilitator methods you may need.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
44
Add two constructors to the Appointment class created in question #9.Include a default constructor and a constructor to initialize an Appointment to suitable arguments.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
45
Write a driver program to test your Student class created in question #14.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 45 في هذه المجموعة.