Deck 4: Defining Classes I

ملء الشاشة (f)
exit full mode
سؤال
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.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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
سؤال
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 an object of a class is called:
(a)instance variable
(b)local variable
(c)global variable
(d)none of the above
سؤال
An object of class A is an instance of class A.
سؤال
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
سؤال
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
سؤال
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.
سؤال
The Java language supports global variables.
سؤال
A method that performs some action other than returning a value is called a __________ method.
(a)null
(b)void
(c)public
(d)private
سؤال
The body of a method that returns a value must contain at least one _________ statement.
(a)void
(b)invocation
(c)thows
(d)return
سؤال
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
سؤال
In Java,call-by-value is only used with:
(a)objects
(b)primitive types
(c)this
(d)all of the above
سؤال
When you want the parameters in a method to be the same as the instance variables you can use the _____ parameter.
(a)String
(b)hidden
(c)default
(d)this
سؤال
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.
سؤال
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 _________ states what is assumed to be true when the method is called.
(a)prescript
(b)postscript
(c)precondition
(d)postcondition
سؤال
In Java,a block is delimited by:
(a)( )
(b)/* */
(c)" "
(d){ }
سؤال
A more eloquent approach in implementing mutator methods is to return a ________ value.
(a)int
(b)char
(c)boolean
(d)double
سؤال
A set method is:
(a)an accessor method
(b)a mutator method
(c)a recursive method
(d)none of the above
سؤال
Write a method called Greeting that displays a personalized greeting given a first name.
سؤال
Mutator methods can return integer values indicating if the change of the instance variable was a success.
سؤال
The modifier private means that an instance variable can be accessed by name outside of the class definition.
سؤال
Boolean expressions may be used to control if-else or while statements.
سؤال
Java supports operator overloading.
سؤال
Method overloading is when two or more methods of the same class have the same name but differ in number or types of parameters.
سؤال
It is considered good programming practice to validate a value passed to a mutator method before setting the instance variable.
سؤال
Only the default constructor has the this parameter.
سؤال
Discuss the public and private modifiers in context of methods and instance variables.
سؤال
Discuss the importance of accessor and mutator methods and how they apply to the abstraction concept.
سؤال
Define the terms arguments and parameters.How are they different?
سؤال
What is the purpose of the new operator?
سؤال
Write a Java method that prints the phrase "Five purple people eaters were seen munching Martians".
سؤال
Write a method called power the computes xn where x and n and positive integers.The method has two integer parameters and returns a value of type long.
سؤال
Write a Java method that returns the value of PI,where PI = 3.1415926535.
سؤال
Discuss a situation in which it is appropriate to use the this parameter.
سؤال
Write a method called isEqual that returns a Boolean value.The method compares two integers for equality.
سؤال
When you give a command to run a Java program,the runtime system invokes the class constructor.
سؤال
Inside a Java method definition,you can use the keyword this as a name for the calling object.
سؤال
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 driver program to test your Student class created in question #14.
سؤال
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 preconditions and postconditions for the power method you wrote in question #4.
سؤال
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.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/44
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Defining Classes I
1
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.
True
2
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
B
3
The parameter this refers to
(a)instance variables
(b)local variables
(c)global variables
(d)the calling object
D
4
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
5
An object of class A is an instance of class A.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
6
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
7
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
8
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
9
The Java language supports global variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
10
A method that performs some action other than returning a value is called a __________ method.
(a)null
(b)void
(c)public
(d)private
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
11
The body of a method that returns a value must contain at least one _________ statement.
(a)void
(b)invocation
(c)thows
(d)return
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
12
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
13
In Java,call-by-value is only used with:
(a)objects
(b)primitive types
(c)this
(d)all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
14
When you want the parameters in a method to be the same as the instance variables you can use the _____ parameter.
(a)String
(b)hidden
(c)default
(d)this
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
15
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
16
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
17
A _________ states what is assumed to be true when the method is called.
(a)prescript
(b)postscript
(c)precondition
(d)postcondition
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
18
In Java,a block is delimited by:
(a)( )
(b)/* */
(c)" "
(d){ }
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
19
A more eloquent approach in implementing mutator methods is to return a ________ value.
(a)int
(b)char
(c)boolean
(d)double
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
20
A set method is:
(a)an accessor method
(b)a mutator method
(c)a recursive method
(d)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
21
Write a method called Greeting that displays a personalized greeting given a first name.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
22
Mutator methods can return integer values indicating if the change of the instance variable was a success.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
23
The modifier private means that an instance variable can be accessed by name outside of the class definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
24
Boolean expressions may be used to control if-else or while statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
25
Java supports operator overloading.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
26
Method overloading is when two or more methods of the same class have the same name but differ in number or types of parameters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
27
It is considered good programming practice to validate a value passed to a mutator method before setting the instance variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
28
Only the default constructor has the this parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
29
Discuss the public and private modifiers in context of methods and instance variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
30
Discuss the importance of accessor and mutator methods and how they apply to the abstraction concept.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
31
Define the terms arguments and parameters.How are they different?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
32
What is the purpose of the new operator?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
33
Write a Java method that prints the phrase "Five purple people eaters were seen munching Martians".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
34
Write a method called power the computes xn where x and n and positive integers.The method has two integer parameters and returns a value of type long.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
35
Write a Java method that returns the value of PI,where PI = 3.1415926535.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
36
Discuss a situation in which it is appropriate to use the this parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
37
Write a method called isEqual that returns a Boolean value.The method compares two integers for equality.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
38
When you give a command to run a Java program,the runtime system invokes the class constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
39
Inside a Java method definition,you can use the keyword this as a name for the calling object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
40
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
41
Write a driver program to test your Student class created in question #14.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
42
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
43
Write preconditions and postconditions for the power method you wrote in question #4.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
44
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.