Deck 4: Writing Classes

ملء الشاشة (f)
exit full mode
سؤال
Consider a sequence of method invocations as follows: main calls m1, m1 calls m2, m2 calls m3 and then m2 calls m4, m3 calls m5. If m4 has just terminated, what method will resume execution?

A) m1
B) m2
C) m3
D) m5
E) main
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Instance data for a Java class

A) are limited to primitive types (e.g., int, float, char)
B) are limited to Strings
C) are limited to objects(e.g., Strings, classes defined by other programmers)
D) may be primitive types or objects, but objects must be defined to be private
E) may be primitive types or objects
سؤال
Consider a Rational class designed to represent rational numbers as a pair of int's, along with methods reduce (to reduce the rational to simplest form), gcd (to find the greatest common divisor of two int's), as well as methods for addition, subtraction, multiplication, and division. Why should the reduce and gcd methods be declared to be private.

A) Because they will never be used
B) Because they will only be called from methods inside of Rational
C) Because they will only be called from the constructor of Rational
D) Because they do not use any of Rational's instance data
E) Because it is a typo and they should be declared as public
سؤال
To define a class that will represent a car, which of the following definitions is most appropriate?

A) private class car
B) public class car
C) public class Car
D) public class CAR
E) private class Car
سؤال
For the questions below, use the following class definition.
import java.text.DecimalFormat;
public class Student
{
private String name;
private String major;
private double gpa;
private int hours;
public Student(String newName, String newMajor, double newGPA, int newHours)
{
name = newName;
major = newMajor;
gpa = newGPA;
hours = newHours;
}
public String toString( )
{
DecimalFormat df = new DecimalFormat("xxxx"); // xxxx needs to be replaced
return name + "\n" + major + "\n" + df.format(gpa) + "\n" + hours
}
}
Assume that another method has been defined that will compute and return the student's class rank (Freshman, Sophomore, etc). It is defined as: public String getClassRank( )
Given that s1 is a student, which of the following would properly be used to get s1's class rank?

A) s1 = getClassRank( );
B) s1.toString( );
C) s1.getHours( );
D) s1.getClassRank( );
E) getClassRank(s1);
سؤال
A class' constructor usually defines

A) how an object is initialized
B) how an object is interfaced
C) the number of instance data in the class
D) the number of methods in the class
E) if the instance data are accessible outside of the object directly
سؤال
If a method does not have a return statement, then

A) it will produce a syntax error when compiled
B) it must be a void method
C) it can not be called from outside the class that defined the method
D) it must be defined to be a public method
E) it must be an int, double, float or String method
سؤال
Which of the following Applet methods is called automatically when the applet is first loaded?

A) Applet (the Applet's constructor)
B) init
C) start
D) getCodeBase
E) getImage
سؤال
For the questions below, use the following class definition.
import java.text.DecimalFormat;
public class Student
{
private String name;
private String major;
private double gpa;
private int hours;
public Student(String newName, String newMajor, double newGPA, int newHours)
{
name = newName;
major = newMajor;
gpa = newGPA;
hours = newHours;
}
public String toString( )
{
DecimalFormat df = new DecimalFormat("xxxx"); // xxxx needs to be replaced
return name + "\n" + major + "\n" + df.format(gpa) + "\n" + hours
}
}
Which of the following patterns should be used in place of "xxxx" when instantiating df so that the gpa to be output in typical form (like 3.810)?

A) "#.###"
B) "#.0"
C) "0.# "
D) "0.000"
E) "0.0##"
سؤال
Having multiple class methods of the same name where each method has a different number of or type of parameters is known as

A) encapsulation
B) information hiding
C) tokenizing
D) importing
E) method overloading
سؤال
StringTokenizer is a class in the java.util library that can divide a String based on some delimiter String (a delimiter is a separator). If the instruction StringTokener st = new StringTokenizer(str, "&&"); is executed, where str is some String, then st divides up str into separate Strings whenever

A) a blank space is found
B) two blank spaces are found
C) a single ampersand ("&") is found
D) two ampersands are found
E) two ampersands or the substring "and" or "AND" is found
سؤال
A variable whose scope is restricted to the method where it was declared is known as a(n)

A) parameter
B) global variable
C) local variable
D) public instance data
E) private instance data
سؤال
Another method that might be desired is one that updates the Student's number of credit hours. This method will receive a number of credit hours and add these to the Student's current hours. Which of the following methods would accomplish this?

A) public int updateHours( ) { return hours; }
B) public void updateHours( ) { hours++; }
C) public updateHours(int moreHours) { hours += moreHours; }
D) public void updateHours(int moreHours) { hours += moreHours; }
E) public int updateHours(int moreHours) { return hours + moreHours; }
سؤال
Consider a method defined with the header: public void foo(int a, int b). Which of the following method calls is legal?

A) foo(0, 0.1);
B) foo(0 / 1, 2 * 3);
C) foo(0);
D) foo( );
E) foo(1 + 2, 3 * 0.1);
سؤال
The behavior of an object is defined by the object's

A) instance data
B) constructor
C) visibility modifiers
D) methods
E) all of the above
سؤال
The relationship between a class and an object is best described as

A) classes are instances of objects
B) objects are instances of classes
C) objects and classes are the same thing
D) classes are programs while objects are variables
E) objects are the instance data of classes
سؤال
Which of the following reserved words in Java is used to create an instance of a class?

A) class
B) public
C) public or private, either could be used
D) import
E) new
سؤال
An example of passing message to a String where the message has a String parameter would occur in which of the following messages?

A) length
B) substring
C) equals
D) toUpperCase
E) none of the above, it is not possible to pass a String as a parameter in a message to a String
سؤال
For the questions below, use the following class definition.
import java.text.DecimalFormat;
public class Student
{
private String name;
private String major;
private double gpa;
private int hours;
public Student(String newName, String newMajor, double newGPA, int newHours)
{
name = newName;
major = newMajor;
gpa = newGPA;
hours = newHours;
}
public String toString( )
{
DecimalFormat df = new DecimalFormat("xxxx"); // xxxx needs to be replaced
return name + "\n" + major + "\n" + df.format(gpa) + "\n" + hours
}
}
Which of the following could be used to instantiate a new Student s1?

A) Student s1 = new Student( );
B) s1 = new Student( );
C) Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);
D) new Student s1 = ("Jane Doe", "Computer Science", 3.333, 33);
E) new Student(s1);
سؤال
In order to preserve encapsulation of an object, we would do all of the following except for which one?

A) Make the instance data private
B) Define the methods in the class to access and manipulate the instance data
C) Make the methods of the class public
D) Make the class final
E) All of the above preserve encapsulation
سؤال
A GUI container is an object that defines a screen element.
سؤال
A constructor may contain a return statement so long as no value (or expression) is returned.
سؤال
Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.
سؤال
The interface of a class is based on those data instances and methods that are declared public.
سؤال
Every class definition must include a constructor.
سؤال
Defining formal parameters requires including each parameters type.
سؤال
What happens if you declare a class constructor to have a void return type?

A) You'll likely receive a syntax error
B) The program will compile with a warning, but you'll get a runtime error
C) There's nothing wrong with declaring a constructor to be void
D) The class' default constructor will be used instead of the one you're declaring
E) None of the above
سؤال
Java methods can return more than one item if they are modified with the reserved word continue, as in public continue int foo( ) { ... }
سؤال
The following method header definition will result in a syntax error: public void aMethod( );
سؤال
The expressions that are passed to a method in an invocation are called

A) actual parameters
B) formal parameters
C) formal arguments
D) formals
E) any of the above
سؤال
All Java classes must contain a main method which is the first method executed when the Java class is called upon.
سؤال
In a UML diagram for a class

A) classes are represented as rectangles
B) there may be a section containing the name of the class
C) there may be a section containing the attributes (data) of the class
D) there may be a section containing the methods of the class
E) all of the above
سؤال
Java methods can return only primitive types (int, double, float, char, boolean, etc).
سؤال
The software failure at the Denver International Airport's baggage handling system is a good example of

A) how a large system can be obsolete by the time it is developed
B) how designers sometimes have too much faith in the technology they are using
C) how failures are often a result of multiple variables caused by a system as a whole in actual operation
D) how the use of a centralized computer is really unrealistic in today's distributed processing
E) all of the above
سؤال
Listener objects "wait" for an event to occur.
سؤال
A method defined in a class can access the class' instance data without needing to pass them as parameters or declare them as local variables.
سؤال
Visibility modifiers include

A) public, private
B) public, private, protected
C) public, private, protected, final
D) public, protected, final, static
E) public, private, protected, static
سؤال
What are the objects needed in order to create a Java GUI (graphical user interface)?

A) components
B) events
C) listeners
D) all of the above
E) only classes from AWT and/or Swing are needed
سؤال
Consider a method defined with the header: public void doublefoo(double x). Which of the following method calls is legal?

A) doublefoo(0);
B) doublefoo(0.555);
C) doublefoo(0.1 + 0.2);
D) doublefoo(0.1, 0.2);
E) all of the above are legal except for D
سؤال
While multiple objects of the same class can exist, in a given program there can be only one version of each class.
سؤال
Write the statement to instantiate an Box object, blueBox, with a length of 6, width of 4, and height of 2.
سؤال
An Employee will have a name, social security number, position, and hourly wages. Define the instance data for this class.
سؤال
Write the constructor, which is passed the player's name and position.
سؤال
Write a statement to output the volume of the blue box.
سؤال
Accessors and mutators provide mechanisms for controlled access to a well-encapsulated class.
سؤال
Write a statement to instantiate a cube with a length of 3, width of 3, and height of 3.
سؤال
Write the constructor for this class.
سؤال
When reasoning about a car, we use such information as its make and model, year, color, cost (or worth), number of miles, gas mileage, insurance cost, and so forth. Consider a program that will attempt to determine how practical a car might be on a road trip. Which of these types of information might you use in your program as instance data?
Provide a justification for your selection.
سؤال
Assume method0 calls method1 and method2, method1 calls method3 which calls method4 and method5. Explain the chain of method calls (what order methods are called and from which method).
سؤال
Consider the "Push Me!" program described in section 4.7. As given the push counter starts at zero and is incremented each time the "Push Me!" button is pressed. Let's say that you want to add a class called ResetListener that resets the count to zero. Write the ResetListener class.
سؤال
Explain why it would be a poor decision to make instance data public instead of private. Give an example of why this could result in a problem.
سؤال
Write a toString method that returns the player's name, position and batting average formatted to have 1 digit to the left of the decimal and 3 digits to the right of the decimal. Assume DecimalFormat has been imported.
سؤال
What visibility modifiers would you use for the methods that move the elevator up one floor, move the elevator down one floor, that request the elevator, and that start the elevator moving?
سؤال
Add a constructor to class Box for a cube, which has only 1 parameter, side.
سؤال
An object should be encapsulated in order to guard its data and methods from inappropriate access.
سؤال
Regarding the software failure described at the Denver International Airport, it is critical to factor in errors and inefficiencies that always occur in a complex system.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/56
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Writing Classes
1
Consider a sequence of method invocations as follows: main calls m1, m1 calls m2, m2 calls m3 and then m2 calls m4, m3 calls m5. If m4 has just terminated, what method will resume execution?

A) m1
B) m2
C) m3
D) m5
E) main
B
Explanation: B) Once a method terminates, control resumes with the method that called that method. In this case, m2 calls m4, so that when m4 terminates, m2 is resumed.
2
Instance data for a Java class

A) are limited to primitive types (e.g., int, float, char)
B) are limited to Strings
C) are limited to objects(e.g., Strings, classes defined by other programmers)
D) may be primitive types or objects, but objects must be defined to be private
E) may be primitive types or objects
E
Explanation: E) The instance data are the entities that make up the class and may be any type available whether primitive or object, and may be public or private. By using objects as instance data, it permits the class to be built upon other classes. This relationship where a class has instance data that are other classes is known as a has-a relationship.
3
Consider a Rational class designed to represent rational numbers as a pair of int's, along with methods reduce (to reduce the rational to simplest form), gcd (to find the greatest common divisor of two int's), as well as methods for addition, subtraction, multiplication, and division. Why should the reduce and gcd methods be declared to be private.

A) Because they will never be used
B) Because they will only be called from methods inside of Rational
C) Because they will only be called from the constructor of Rational
D) Because they do not use any of Rational's instance data
E) Because it is a typo and they should be declared as public
B
Explanation: B) All items of a class that are declared to be private are only accessible to entities within that class, whether they are instance data or methods. In this case, since these two methods are only called from other methods (including the constructor) of Rational, they are declared private to promote information hiding to a greater degree. Note that answer C is not a correct answer because the reduce method calls the gcd method, so one of the methods is called from a method other than the constructor.
4
To define a class that will represent a car, which of the following definitions is most appropriate?

A) private class car
B) public class car
C) public class Car
D) public class CAR
E) private class Car
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
5
For the questions below, use the following class definition.
import java.text.DecimalFormat;
public class Student
{
private String name;
private String major;
private double gpa;
private int hours;
public Student(String newName, String newMajor, double newGPA, int newHours)
{
name = newName;
major = newMajor;
gpa = newGPA;
hours = newHours;
}
public String toString( )
{
DecimalFormat df = new DecimalFormat("xxxx"); // xxxx needs to be replaced
return name + "\n" + major + "\n" + df.format(gpa) + "\n" + hours
}
}
Assume that another method has been defined that will compute and return the student's class rank (Freshman, Sophomore, etc). It is defined as: public String getClassRank( )
Given that s1 is a student, which of the following would properly be used to get s1's class rank?

A) s1 = getClassRank( );
B) s1.toString( );
C) s1.getHours( );
D) s1.getClassRank( );
E) getClassRank(s1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
6
A class' constructor usually defines

A) how an object is initialized
B) how an object is interfaced
C) the number of instance data in the class
D) the number of methods in the class
E) if the instance data are accessible outside of the object directly
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
7
If a method does not have a return statement, then

A) it will produce a syntax error when compiled
B) it must be a void method
C) it can not be called from outside the class that defined the method
D) it must be defined to be a public method
E) it must be an int, double, float or String method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which of the following Applet methods is called automatically when the applet is first loaded?

A) Applet (the Applet's constructor)
B) init
C) start
D) getCodeBase
E) getImage
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
9
For the questions below, use the following class definition.
import java.text.DecimalFormat;
public class Student
{
private String name;
private String major;
private double gpa;
private int hours;
public Student(String newName, String newMajor, double newGPA, int newHours)
{
name = newName;
major = newMajor;
gpa = newGPA;
hours = newHours;
}
public String toString( )
{
DecimalFormat df = new DecimalFormat("xxxx"); // xxxx needs to be replaced
return name + "\n" + major + "\n" + df.format(gpa) + "\n" + hours
}
}
Which of the following patterns should be used in place of "xxxx" when instantiating df so that the gpa to be output in typical form (like 3.810)?

A) "#.###"
B) "#.0"
C) "0.# "
D) "0.000"
E) "0.0##"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
10
Having multiple class methods of the same name where each method has a different number of or type of parameters is known as

A) encapsulation
B) information hiding
C) tokenizing
D) importing
E) method overloading
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
11
StringTokenizer is a class in the java.util library that can divide a String based on some delimiter String (a delimiter is a separator). If the instruction StringTokener st = new StringTokenizer(str, "&&"); is executed, where str is some String, then st divides up str into separate Strings whenever

A) a blank space is found
B) two blank spaces are found
C) a single ampersand ("&") is found
D) two ampersands are found
E) two ampersands or the substring "and" or "AND" is found
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
12
A variable whose scope is restricted to the method where it was declared is known as a(n)

A) parameter
B) global variable
C) local variable
D) public instance data
E) private instance data
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
13
Another method that might be desired is one that updates the Student's number of credit hours. This method will receive a number of credit hours and add these to the Student's current hours. Which of the following methods would accomplish this?

A) public int updateHours( ) { return hours; }
B) public void updateHours( ) { hours++; }
C) public updateHours(int moreHours) { hours += moreHours; }
D) public void updateHours(int moreHours) { hours += moreHours; }
E) public int updateHours(int moreHours) { return hours + moreHours; }
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
14
Consider a method defined with the header: public void foo(int a, int b). Which of the following method calls is legal?

A) foo(0, 0.1);
B) foo(0 / 1, 2 * 3);
C) foo(0);
D) foo( );
E) foo(1 + 2, 3 * 0.1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
15
The behavior of an object is defined by the object's

A) instance data
B) constructor
C) visibility modifiers
D) methods
E) all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
16
The relationship between a class and an object is best described as

A) classes are instances of objects
B) objects are instances of classes
C) objects and classes are the same thing
D) classes are programs while objects are variables
E) objects are the instance data of classes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which of the following reserved words in Java is used to create an instance of a class?

A) class
B) public
C) public or private, either could be used
D) import
E) new
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
18
An example of passing message to a String where the message has a String parameter would occur in which of the following messages?

A) length
B) substring
C) equals
D) toUpperCase
E) none of the above, it is not possible to pass a String as a parameter in a message to a String
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
19
For the questions below, use the following class definition.
import java.text.DecimalFormat;
public class Student
{
private String name;
private String major;
private double gpa;
private int hours;
public Student(String newName, String newMajor, double newGPA, int newHours)
{
name = newName;
major = newMajor;
gpa = newGPA;
hours = newHours;
}
public String toString( )
{
DecimalFormat df = new DecimalFormat("xxxx"); // xxxx needs to be replaced
return name + "\n" + major + "\n" + df.format(gpa) + "\n" + hours
}
}
Which of the following could be used to instantiate a new Student s1?

A) Student s1 = new Student( );
B) s1 = new Student( );
C) Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);
D) new Student s1 = ("Jane Doe", "Computer Science", 3.333, 33);
E) new Student(s1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
20
In order to preserve encapsulation of an object, we would do all of the following except for which one?

A) Make the instance data private
B) Define the methods in the class to access and manipulate the instance data
C) Make the methods of the class public
D) Make the class final
E) All of the above preserve encapsulation
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
21
A GUI container is an object that defines a screen element.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
22
A constructor may contain a return statement so long as no value (or expression) is returned.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
23
Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
24
The interface of a class is based on those data instances and methods that are declared public.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
25
Every class definition must include a constructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
26
Defining formal parameters requires including each parameters type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
27
What happens if you declare a class constructor to have a void return type?

A) You'll likely receive a syntax error
B) The program will compile with a warning, but you'll get a runtime error
C) There's nothing wrong with declaring a constructor to be void
D) The class' default constructor will be used instead of the one you're declaring
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
28
Java methods can return more than one item if they are modified with the reserved word continue, as in public continue int foo( ) { ... }
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
29
The following method header definition will result in a syntax error: public void aMethod( );
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
30
The expressions that are passed to a method in an invocation are called

A) actual parameters
B) formal parameters
C) formal arguments
D) formals
E) any of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
31
All Java classes must contain a main method which is the first method executed when the Java class is called upon.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
32
In a UML diagram for a class

A) classes are represented as rectangles
B) there may be a section containing the name of the class
C) there may be a section containing the attributes (data) of the class
D) there may be a section containing the methods of the class
E) all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
33
Java methods can return only primitive types (int, double, float, char, boolean, etc).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
34
The software failure at the Denver International Airport's baggage handling system is a good example of

A) how a large system can be obsolete by the time it is developed
B) how designers sometimes have too much faith in the technology they are using
C) how failures are often a result of multiple variables caused by a system as a whole in actual operation
D) how the use of a centralized computer is really unrealistic in today's distributed processing
E) all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
35
Listener objects "wait" for an event to occur.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
36
A method defined in a class can access the class' instance data without needing to pass them as parameters or declare them as local variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
37
Visibility modifiers include

A) public, private
B) public, private, protected
C) public, private, protected, final
D) public, protected, final, static
E) public, private, protected, static
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
38
What are the objects needed in order to create a Java GUI (graphical user interface)?

A) components
B) events
C) listeners
D) all of the above
E) only classes from AWT and/or Swing are needed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
39
Consider a method defined with the header: public void doublefoo(double x). Which of the following method calls is legal?

A) doublefoo(0);
B) doublefoo(0.555);
C) doublefoo(0.1 + 0.2);
D) doublefoo(0.1, 0.2);
E) all of the above are legal except for D
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
40
While multiple objects of the same class can exist, in a given program there can be only one version of each class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
41
Write the statement to instantiate an Box object, blueBox, with a length of 6, width of 4, and height of 2.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
42
An Employee will have a name, social security number, position, and hourly wages. Define the instance data for this class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
43
Write the constructor, which is passed the player's name and position.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
44
Write a statement to output the volume of the blue box.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
45
Accessors and mutators provide mechanisms for controlled access to a well-encapsulated class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
46
Write a statement to instantiate a cube with a length of 3, width of 3, and height of 3.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
47
Write the constructor for this class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
48
When reasoning about a car, we use such information as its make and model, year, color, cost (or worth), number of miles, gas mileage, insurance cost, and so forth. Consider a program that will attempt to determine how practical a car might be on a road trip. Which of these types of information might you use in your program as instance data?
Provide a justification for your selection.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
49
Assume method0 calls method1 and method2, method1 calls method3 which calls method4 and method5. Explain the chain of method calls (what order methods are called and from which method).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
50
Consider the "Push Me!" program described in section 4.7. As given the push counter starts at zero and is incremented each time the "Push Me!" button is pressed. Let's say that you want to add a class called ResetListener that resets the count to zero. Write the ResetListener class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
51
Explain why it would be a poor decision to make instance data public instead of private. Give an example of why this could result in a problem.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
52
Write a toString method that returns the player's name, position and batting average formatted to have 1 digit to the left of the decimal and 3 digits to the right of the decimal. Assume DecimalFormat has been imported.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
53
What visibility modifiers would you use for the methods that move the elevator up one floor, move the elevator down one floor, that request the elevator, and that start the elevator moving?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
54
Add a constructor to class Box for a cube, which has only 1 parameter, side.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
55
An object should be encapsulated in order to guard its data and methods from inappropriate access.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
56
Regarding the software failure described at the Denver International Airport, it is critical to factor in errors and inefficiencies that always occur in a complex system.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 56 في هذه المجموعة.