Deck 7: Object-Oriented Design
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/76
Play
Full screen (f)
Deck 7: Object-Oriented Design
1
Java does not support multiple inheritance, but some of the abilities of multiple inheritance are available by
A) importing classes
B) implementing interfaces
C) overriding parent class methods
D) creating aliases
E) using public rather than protected or private modifiers
A) importing classes
B) implementing interfaces
C) overriding parent class methods
D) creating aliases
E) using public rather than protected or private modifiers
B
Explanation: B) Since a class can implement any number of interfaces, that class is in essence using the interface classes as if those interfaces were defined in this class. So, this class is inheriting the methods and constants of the interfaces. Further, the class could extend another class and thus inherit directly and indirectly from multiple classes. This is not the exact same as multiple inheritance, but it is as close as Java comes to that concept.
Explanation: B) Since a class can implement any number of interfaces, that class is in essence using the interface classes as if those interfaces were defined in this class. So, this class is inheriting the methods and constants of the interfaces. Further, the class could extend another class and thus inherit directly and indirectly from multiple classes. This is not the exact same as multiple inheritance, but it is as close as Java comes to that concept.
2
In general, spending more time in development to ensure better software will
A) shorten testing time
B) slightly reduce maintenance efforts
C) slightly increase maintenance efforts
D) greatly reduce maintenance efforts
E) not alter the time it takes for any other stage whatsoever
A) shorten testing time
B) slightly reduce maintenance efforts
C) slightly increase maintenance efforts
D) greatly reduce maintenance efforts
E) not alter the time it takes for any other stage whatsoever
D
Explanation: D) Spending more time in development promises better software, which in turn leads to less maintenance effort.
Explanation: D) Spending more time in development promises better software, which in turn leads to less maintenance effort.
3
Which of the following is not a method of the Object class?
A) clone
B) compareTo
C) equals
D) toString
E) all of the above are methods of the Object class
A) clone
B) compareTo
C) equals
D) toString
E) all of the above are methods of the Object class
B
Explanation: B) The Object class defines clone to create a copy of any object, equals to determine if two objects are the same object, and toString to translate an Object into a String. However, compareTo is not implement by Object and must be explicitly implemented in any class that wants to implement the Comparable interface.
Explanation: B) The Object class defines clone to create a copy of any object, equals to determine if two objects are the same object, and toString to translate an Object into a String. However, compareTo is not implement by Object and must be explicitly implemented in any class that wants to implement the Comparable interface.
4
An example of an aggregation relationship is
A) parent and child
B) animal and dog
C) teacher and computer
D) phone and fax machine
E) all of the above
A) parent and child
B) animal and dog
C) teacher and computer
D) phone and fax machine
E) all of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
5
During program development, software requirements specify
A) how the program will accomplish the task
B) what the task is that the program must perform
C) how to divide the task into subtasks
D) how to test the program when it is done
E) all of the above
A) how the program will accomplish the task
B) what the task is that the program must perform
C) how to divide the task into subtasks
D) how to test the program when it is done
E) all of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
6
The activities of the development cycle are generally thought to
A) be strictly linear
B) be rigidly ordered
C) overlap
D) have optional steps
E) both A and B are True
A) be strictly linear
B) be rigidly ordered
C) overlap
D) have optional steps
E) both A and B are True
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
7
Inheritance through an extended (derived) class supports which of the following concepts?
A) interfaces
B) modulary
C) information hiding
D) code reuse
E) correctness
A) interfaces
B) modulary
C) information hiding
D) code reuse
E) correctness
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
8
The idea of having programmers and developers meet in order to critique a software design or implementation is known as
A) an interview
B) a walkthrough
C) prototyping
D) aggregation
E) evolutionary development
A) an interview
B) a walkthrough
C) prototyping
D) aggregation
E) evolutionary development
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
9
Static methods cannot
A) reference instance data
B) reference non-static instance data
C) reference other objects
D) invoke other static methods
E) invoke non-static methods
A) reference instance data
B) reference non-static instance data
C) reference other objects
D) invoke other static methods
E) invoke non-static methods
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
10
Abstract methods are used when defining
A) interface classes
B) derived classes
C) classes that have no constructor
D) arrays
E) classes that have no methods
A) interface classes
B) derived classes
C) classes that have no constructor
D) arrays
E) classes that have no methods
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
11
It is easier to correct errors found in a program if
A) they are identified early in the development cycle
B) they are identified during testing
C) they are identified during program use
D) they are identified during maintenance
E) all of the above are equally True, errors are easily corrected in any of these stages
A) they are identified early in the development cycle
B) they are identified during testing
C) they are identified during program use
D) they are identified during maintenance
E) all of the above are equally True, errors are easily corrected in any of these stages
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following methods is a static method? The class in which the method is defined is given in parentheses following the method name.
A) equals (String)
B) toUpperCase (String)
C) sqrt (Math)
D) format (DecimalFormat)
E) paint (Applet)
A) equals (String)
B) toUpperCase (String)
C) sqrt (Math)
D) format (DecimalFormat)
E) paint (Applet)
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
13
The idea that an object can exist separate from the executing program that creates it is called
A) transience
B) static
C) persistence
D) serialization
E) finality
A) transience
B) static
C) persistence
D) serialization
E) finality
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following interfaces would be used to implement a class that represents a group (or collection) of objects?
A) Iterator
B) Speaker
C) Comparable
D) MouseListener
E) KeyListener
A) Iterator
B) Speaker
C) Comparable
D) MouseListener
E) KeyListener
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
15
An object that refers to part of itself within its own methods can use which of the following reserved words to denote this relationship?
A) inner
B) i
C) private
D) this
E) static
A) inner
B) i
C) private
D) this
E) static
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
16
A bad programming habit is to build an initial program and then spend a great deal of time modifying the code until it is acceptable. This is known as
A) the prototyping approach
B) the waterfall model
C) iterative development
D) the recursive approach
E) the build-and-fix approach
A) the prototyping approach
B) the waterfall model
C) iterative development
D) the recursive approach
E) the build-and-fix approach
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
17
Modifying a program in order to eliminate deficiencies is done in the ________ phase of the development cycle.
A) design
B) implementation
C) testing
D) use
E) maintenance
A) design
B) implementation
C) testing
D) use
E) maintenance
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
18
Of the various phases in software development, which of the following is usually the lengthiest?
A) specification
B) design
C) implementation
D) testing
E) maintenance
A) specification
B) design
C) implementation
D) testing
E) maintenance
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
19
In order to create a constant, you would use which of the following Java reserved words?
A) private
B) static
C) int
D) final
E) class
A) private
B) static
C) int
D) final
E) class
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
20
Once we have implemented the solution, we are not done with the problem because
A) the solution may not be the best (most efficient)
B) the solution may have errors and need testing and fixing before we are done
C) the solution may, at a later date, need revising to handle new specifications
D) the solution may, at a later date, need revising because of new programming language features
E) all of the above
A) the solution may not be the best (most efficient)
B) the solution may have errors and need testing and fixing before we are done
C) the solution may, at a later date, need revising to handle new specifications
D) the solution may, at a later date, need revising because of new programming language features
E) all of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following is considered a top-level container?
A) Panel
B) Frame
C) Box
D) Layout Manager
E) A, B, and C
A) Panel
B) Frame
C) Box
D) Layout Manager
E) A, B, and C
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
22
In using the BoxLayout, adding space between components in a container can be accomplished by
A) including TabbedPanes
B) including JButtons that have no names and thus will appear invisible
C) adding invisible components
D) inserting IconImages of blank images
E) any of the above
A) including TabbedPanes
B) including JButtons that have no names and thus will appear invisible
C) adding invisible components
D) inserting IconImages of blank images
E) any of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
23
The JFrame below has a JBorder created using which of the following BorderFactory formats?

A) TitledBorder
B) MatteBorder
C) EtchedBorder
D) RaisedBevelBorder
E) LoweredBevelBorder

A) TitledBorder
B) MatteBorder
C) EtchedBorder
D) RaisedBevelBorder
E) LoweredBevelBorder
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
24
Which Layout Manager type would you use if you want GUI components to be placed at the North, South, East, West and Center of the container?
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
25
What is wrong with the following message to create a BoxLayout for the JPanel jp?
Jp)setLayout(new BoxLayout(BoxLayout.X_AXIS));
A) X_AXIS is not a valid constant for BoxLayout, it should instead be HORIZONTAL
B) Aside from X_AXIS, the constructor also requires a Dimension to determine the size of the Box
C) Aside from X_AXIS, the constructor also needs a command regarding horizontal glue as in createHorizontalGlue( )
D) The BoxLayout constructor is lacking a reference to the container that the BoxLayout manager will govern
E) There is nothing wrong with it at all
Jp)setLayout(new BoxLayout(BoxLayout.X_AXIS));
A) X_AXIS is not a valid constant for BoxLayout, it should instead be HORIZONTAL
B) Aside from X_AXIS, the constructor also requires a Dimension to determine the size of the Box
C) Aside from X_AXIS, the constructor also needs a command regarding horizontal glue as in createHorizontalGlue( )
D) The BoxLayout constructor is lacking a reference to the container that the BoxLayout manager will govern
E) There is nothing wrong with it at all
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
26
The goal of testing is to
A) ensure that the software has no errors
B) find syntax errors
C) find logical and run-time errors
D) evaluate how well the software meets the original requirements
E) give out-of-work programmers something to do
A) ensure that the software has no errors
B) find syntax errors
C) find logical and run-time errors
D) evaluate how well the software meets the original requirements
E) give out-of-work programmers something to do
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
27
To take 2 borders and use one as an outer border and the other as an inner border, you would create a
A) compound border
B) nested border
C) split border
D) border factory
E) matte border
A) compound border
B) nested border
C) split border
D) border factory
E) matte border
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
28
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
A) encapsulation
B) information hiding
C) tokenizing
D) importing
E) method overloading
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
29
Arranging components in a GUI container is accomplished by using which of the following?
A) Layout manager
B) Listener interface
C) String array
D) Event generator
E) JComboBox
A) Layout manager
B) Listener interface
C) String array
D) Event generator
E) JComboBox
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
30
In which phase of program development would you expect the programmer(s) to determine the classes and objects needed?
A) software requirements
B) software design
C) software implementation
D) software testing
E) could occur in any of the above
A) software requirements
B) software design
C) software implementation
D) software testing
E) could occur in any of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
31
Which Layout Manager type would you use if you want GUI components to be placed in 2 columns over 5 rows?
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
32
In which phase of program development would you expect the programmer(s) to create the pseudocode?
A) Software requirements
B) Software design
C) Software implementation
D) Software testing
E) Could occur in any of the above
A) Software requirements
B) Software design
C) Software implementation
D) Software testing
E) Could occur in any of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
33
It is important to dissect a problem into manageable pieces before trying to solve the problem because
A) most problems are too complex to be solved as a single, large activity
B) most problems are solved by multiple people and it is easy to assign each piece to a separate person
C) it is easier to integrate small pieces of a program into one program than it is to integrate one big chunk of code into one program
D) our first solution may not solve the problem correctly
E) all of the above
A) most problems are too complex to be solved as a single, large activity
B) most problems are solved by multiple people and it is easy to assign each piece to a separate person
C) it is easier to integrate small pieces of a program into one program than it is to integrate one big chunk of code into one program
D) our first solution may not solve the problem correctly
E) all of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
34
For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The variable type will store "King", "Queen", "Bishop", etc and the int player will store 0 or 1 depending on whose piece it is. We wish to implement Comparable for the ChessPiece class. Assume that, the current ChessPiece is compared to a ChessPiece passed as a parameter. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King."
Which of the following would not be considered an algorithm?
A) a recipe
B) a computer program
C) pseudocode
D) a shopping list
E) travel directions
Which of the following would not be considered an algorithm?
A) a recipe
B) a computer program
C) pseudocode
D) a shopping list
E) travel directions
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
35
In order to implement Comparable in a class, what method(s) must be defined in that class?
A) equals
B) compares
C) both lessThan and greaterThan
D) compareTo
E) both compares and equals
A) equals
B) compares
C) both lessThan and greaterThan
D) compareTo
E) both compares and equals
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
36
For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The variable type will store "King", "Queen", "Bishop", etc and the int player will store 0 or 1 depending on whose piece it is. We wish to implement Comparable for the ChessPiece class. Assume that, the current ChessPiece is compared to a ChessPiece passed as a parameter. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King."
Which of the following method headers would properly define the method needed to make this class Comparable?
A) public boolean comparable(Object cp)
B) public int comparable(Object cp)
C) public int compareTo(Object cp)
D) public int compareTo( )
E) public boolean compareTo(Object cp)
Which of the following method headers would properly define the method needed to make this class Comparable?
A) public boolean comparable(Object cp)
B) public int comparable(Object cp)
C) public int compareTo(Object cp)
D) public int compareTo( )
E) public boolean compareTo(Object cp)
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
37
Which Layout Manager is used by default if you do not specify a Layout Manager for your GUI container?
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
E) TabbedPane
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the following GUI classes requires that it have a LayoutManager before any GUI components are added to it?
A) JButton
B) JSlider
C) JPanel
D) JFrame
E) both C and D but not A or B
A) JButton
B) JSlider
C) JPanel
D) JFrame
E) both C and D but not A or B
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
39
In order to display three components vertically in a container, you could use all but which of the following layout managers?
A) FlowLayout
B) BoxLayout
C) GridLayout
D) BorderLayout
E) you could use any of the above
A) FlowLayout
B) BoxLayout
C) GridLayout
D) BorderLayout
E) you could use any of the above
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
40
For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The variable type will store "King", "Queen", "Bishop", etc and the int player will store 0 or 1 depending on whose piece it is. We wish to implement Comparable for the ChessPiece class. Assume that, the current ChessPiece is compared to a ChessPiece passed as a parameter. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King."
Which of the following pieces of logic could be used in the method that implements Comparable? Assume that the method is passed Object a, which is really a ChessPiece. Also assume that ChessPiece has a method called returnType which returns the type of the given piece. Only one of these answers has correct logic.
A) if (this.type < a.returnType( )) return -1;
B) if (this.type = = a.returnType( )) return 0;
C) if (this.type.equals(a.returnType( )) return 0;
D) if (a.returnType( ).equals("King")) return -1;
E) if (a.returnType( ).equals("Pawn")) return 1;
Which of the following pieces of logic could be used in the method that implements Comparable? Assume that the method is passed Object a, which is really a ChessPiece. Also assume that ChessPiece has a method called returnType which returns the type of the given piece. Only one of these answers has correct logic.
A) if (this.type < a.returnType( )) return -1;
B) if (this.type = = a.returnType( )) return 0;
C) if (this.type.equals(a.returnType( )) return 0;
D) if (a.returnType( ).equals("King")) return -1;
E) if (a.returnType( ).equals("Pawn")) return 1;
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
41
All objects implement Comparable.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
42
If a GUI container is resized by the user, all components of the GUI are automatically increased or decreased by the same fraction to fit in the newly sized container.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
43
The most important decisions regarding the development of a system are made during the implementation phase while code is actively being written.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
44
Defining formal parameters requires including each parameters type.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
45
In black-box testing, the tester should already know something about how the program is implemented so that he/she can more carefully identify what portion(s) of the software are leading to errors.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
46
The size and shape of a GUI container is based on the layout manager selected and the type and number of items added to the container.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
47
If classes C1 and C2 both implement an interface Cint, which has a method whichIsIt, and if C1 c = new C1( ); is performed at one point of the program, then a later instruction c.whichIsIt( ); will invoke the whichIsIt method defined in C1.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
48
A JPanel can itself contain JPanels.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
49
Interface classes cannot be extended but classes that implement interfaces can be extended.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
50
Provide a reason why a method would be declared static.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
51
A border can be put around any Swing component with the exception of a JButton and JScrollPane component.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
52
Provide a reason why an instance data would be declared static.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
53
It is not possible to test out any single method or class of a system until the entire system has been developed, and so all testing is postponed until after the implementation phase.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
54
Assume that the class Bird has a static method fly( ). If b is a Bird, then to invoke fly, you could do Bird.fly( );.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
55
Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
56
The term "test case" is used to express a set of inputs (or user actions) and the expected outputs to be used in testing out software.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
57
All parts of a container in BorderLayout must be used.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
58
Any class can implement an interface, but no classes can implement more than a single interface.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
59
If a programmer follows the four phases of program development as intended, which of the four phases should require the least amount of creativity?
A) software requirements
B) software design
C) software implementation
D) software testing
E) none of the above, all four levels would require equal creativity
A) software requirements
B) software design
C) software implementation
D) software testing
E) none of the above, all four levels would require equal creativity
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
60
Unlike the String class where you must pass a message to an object (instance) of the class, as in x.length( ), in order to use the Math class, you pass messages directly to the class name, as in Math.abs( ) or Math.sqrt( ).
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
61
Draw the JFrame as you think it would appear given the following set of code:
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JButton jb8 = new JButton("H");
JButton jb9 = new JButton("I");
JPanel jp1 = new JPanel(new BorderLayout( ));
jp1.add(jb1, BorderLayout.NORTH);
jp1.add(jb2, BorderLayout.WEST);
jp1.add(jb3, BorderLayout.EAST);
JPanel jp2 = new JPanel(new BorderLayout( ));
jp2.add(jb4, BorderLayout.WEST);
jp2.add(jb5, BorderLayout.SOUTH);
jp2.add(jb6, BorderLayout.EAST);
JPanel jp3 = new JPanel(new BorderLayout( ));
jp3.add(jb7, BorderLayout.WEST);
jp3.add(jb8, BorderLayout.NORTH);
jp3.add(jb9, BorderLayout.EAST);
JPanel jp4 = new JPanel(new BorderLayout( ));
jp4.add(jp1, BorderLayout.NORTH);
jp4.add(jp2, BorderLayout.EAST);
jp4.add(jp3, BorderLayout.SOUTH);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp4);
jf.pack( );
jf.setVisible(True );
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JButton jb8 = new JButton("H");
JButton jb9 = new JButton("I");
JPanel jp1 = new JPanel(new BorderLayout( ));
jp1.add(jb1, BorderLayout.NORTH);
jp1.add(jb2, BorderLayout.WEST);
jp1.add(jb3, BorderLayout.EAST);
JPanel jp2 = new JPanel(new BorderLayout( ));
jp2.add(jb4, BorderLayout.WEST);
jp2.add(jb5, BorderLayout.SOUTH);
jp2.add(jb6, BorderLayout.EAST);
JPanel jp3 = new JPanel(new BorderLayout( ));
jp3.add(jb7, BorderLayout.WEST);
jp3.add(jb8, BorderLayout.NORTH);
jp3.add(jb9, BorderLayout.EAST);
JPanel jp4 = new JPanel(new BorderLayout( ));
jp4.add(jp1, BorderLayout.NORTH);
jp4.add(jp2, BorderLayout.EAST);
jp4.add(jp3, BorderLayout.SOUTH);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp4);
jf.pack( );
jf.setVisible(True );
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
62
To implement Comparable for the ChessPiece class, the current ChessPiece's type is compared to a ChessPiece passed as a parameter. The method should return 0 if the types are equal, -1 if this piece's type is a lesser piece than the parameter's type, and 1 if this piece's type is a greater piece than the parameter's type. Pieces are ordered as follows: "Pawn" is a lesser piece to a "Knight" and a "Bishop", "Knight" and "Bishop" are equivalent for this example, both are lesser pieces to a "Rook" which is a lesser piece to a "Queen" which is a lesser piece to a "King." Write the proper method to implement Comparable for this class.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
63
Write a static method that is passed two ChessPieces and determines if the two pieces are owned by the same player. It should return True or false.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
64
Assume a class Foo implements Comparable. Without knowing anything else about the Foo class, write an equal method that returns True if the Foo parameter passed to this Foo is equal to this Foo as determined by using the implementation of Comparable.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
65
Why was the Y2K problem a problem of software maintenance and not a problem of software testing?
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
66
Provide code to generate the following JFrame. Each lettered item is a JButton. Hint: Create several JPanels, each one having two or more JButtons and taken up a portion of the JFrame.


Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
67
Provide code to generate the following JFrame. Each lettered item is a JButton. Hint: Create several JPanels, each one having two or more JButtons and taken up a portion of the JFrame.


Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
68
Why should the add( ), subtract( ), multiply( ), divide( ) methods in the RationalNumber class in the textbook be declared to be public, while the gcd( ) method is declared to be private?
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
69
Draw the JFrame as you think it would appear given the following set of code:
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JPanel jp1 = new JPanel(new GridLayout(3, 3));
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jp1.add(jb4);
jp1.add(jb5);
jp1.add(jb6);
jp1.add(jb7);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp1);
jf.pack( );
jf.setVisible(True);
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JPanel jp1 = new JPanel(new GridLayout(3, 3));
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jp1.add(jb4);
jp1.add(jb5);
jp1.add(jb6);
jp1.add(jb7);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp1);
jf.pack( );
jf.setVisible(True);
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
70
Explain the difference between implementing an interface and a derived class.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
71
Draw the JFrame as you think it would appear given the following set of code:
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JButton jb8 = new JButton("H");
JButton jb9 = new JButton("I");
JButton jb10 = new JButton("J");
JButton jb11 = new JButton("K");
JButton jb12 = new JButton("L");
JPanel jp1 = new JPanel( );
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jp1.add(jb4);
JPanel jp2 = new JPanel(new GridLayout(4, 1));
jp2.add(jb5);
jp2.add(jb6);
jp2.add(jb7);
jp2.add(jb8);
JPanel jp3 = new JPanel(new GridLayout(2, 2));
jp3.add(jb9);
jp3.add(jb10);
jp3.add(jb11);
jp3.add(jb12);
JPanel jp4 = new JPanel(new BorderLayout( ));
jp4.add(jp1, BorderLayout.NORTH);
jp4.add(jp2, BorderLayout.EAST);
jp4.add(jp3, BorderLayout.WEST);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp4);
jf.pack( );
jf.setVisible(True);
JButton jb1 = new JButton("A");
JButton jb2 = new JButton("B");
JButton jb3 = new JButton("C");
JButton jb4 = new JButton("D");
JButton jb5 = new JButton("E");
JButton jb6 = new JButton("F");
JButton jb7 = new JButton("G");
JButton jb8 = new JButton("H");
JButton jb9 = new JButton("I");
JButton jb10 = new JButton("J");
JButton jb11 = new JButton("K");
JButton jb12 = new JButton("L");
JPanel jp1 = new JPanel( );
jp1.add(jb1);
jp1.add(jb2);
jp1.add(jb3);
jp1.add(jb4);
JPanel jp2 = new JPanel(new GridLayout(4, 1));
jp2.add(jb5);
jp2.add(jb6);
jp2.add(jb7);
jp2.add(jb8);
JPanel jp3 = new JPanel(new GridLayout(2, 2));
jp3.add(jb9);
jp3.add(jb10);
jp3.add(jb11);
jp3.add(jb12);
JPanel jp4 = new JPanel(new BorderLayout( ));
jp4.add(jp1, BorderLayout.NORTH);
jp4.add(jp2, BorderLayout.EAST);
jp4.add(jp3, BorderLayout.WEST);
JFrame jf = new JFrame( );
jf.getContentPane( ).add(jp4);
jf.pack( );
jf.setVisible(True);
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
72
Define an interface class that contains two int constants, X = 5 and Y = 10 and one int method called useXY which receives no parameters. Call your interface class XYClass
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
73
Write a set of code that will allow a user to select an input image and then place this image in a JLabel lab1 and add lab1 to a JPanel as the northern component in a JFrame using BorderLayout. The JFrame has already been instantiated as jf and the BorderLayout already established. Hint: a JFileChooser returns a File and JLabel requires the String name of a file as an argument. A File can return its name using File class' method getAbsolutePath( )
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
74
In what way is black-box testing better than glass-box testing?
In what way is glass-box testing better than black-box testing?
In what way is glass-box testing better than black-box testing?
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
75
Write code to create a JPanel with 4 JCheckBox GUI components and two JLabels for output, one that says "Current cost is" and the other that outputs the computed cost based on which of the food items has been selected.
Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck
76
Provide code to generate the following JFrame. Each lettered item is a JButton. Hint: Create several JPanels, each one having two or more JButtons and taken up a portion of the JFrame.


Unlock Deck
Unlock for access to all 76 flashcards in this deck.
Unlock Deck
k this deck