Exam 7: Object-Oriented Design

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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. 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.

Free
(Essay)
4.7/5
(38)
Correct Answer:
Verified

JFrame jf = new JFrame( );
JPanel jp1 = new JPanel(new BorderLayout( ));
JPanel jp2 = new JPanel(new FlowLayout( ));
JPanel jp3 = new JPanel(new GridLayout(2, 3));
JButton lab1 = new JButton("A");
JButton lab2 = new JButton("B");
JButton lab3 = new JButton("C");
JButton lab4 = new JButton("D");
JButton lab5 = new JButton("E");
JButton lab6 = new JButton("F");
JButton lab7 = new JButton("G");
JButton lab8 = new JButton("H");
JButton lab9 = new JButton("I");
JButton lab10 = new JButton("J");
JButton lab11 = new JButton("K");
JButton lab12 = new JButton("L");
JButton lab13 = new JButton("M");
jp1.add(lab1, BorderLayout.NORTH);
jp1.add(lab2, BorderLayout.WEST);
jp1.add(lab3, BorderLayout.CENTER);
jp1.add(lab4, BorderLayout.EAST);
jp1.add(lab5, BorderLayout.SOUTH);
jp2.add(lab6);
jp2.add(lab7);
jp3.add(lab8);
jp3.add(lab9);
jp3.add(lab10);
jp3.add(lab11);
jp3.add(lab12);
jp3.add(lab13);
JPanel jp4 = new JPanel(new GridLayout(3, 1));
jp4.add(jp1);
jp4.add(jp2);
jp4.add(jp3);
jf.getContentPane( ).add(jp4);
jf.pack( );
jf.setVisible(True);

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.

Free
(True/False)
5.0/5
(40)
Correct Answer:
Verified

False

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

Free
(Essay)
4.7/5
(41)
Correct Answer:
Verified

public interface XYClass
{
public final int X = 5;
public final int Y = 10;
public int useXY( );
}

Which of the following interfaces would be used to implement a class that represents a group (or collection) of objects?

(Multiple Choice)
4.9/5
(44)

It is important to dissect a problem into manageable pieces before trying to solve the problem because

(Multiple Choice)
4.7/5
(35)

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.

(True/False)
4.9/5
(34)

In general, spending more time in development to ensure better software will

(Multiple Choice)
4.8/5
(35)

Assume that the class Bird has a static method fly( ). If b is a Bird, then to invoke fly, you could do Bird.fly( );.

(True/False)
4.9/5
(32)

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);

(Essay)
4.9/5
(42)

Arranging components in a GUI container is accomplished by using which of the following?

(Multiple Choice)
4.8/5
(39)

Any class can implement an interface, but no classes can implement more than a single interface.

(True/False)
4.8/5
(36)

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.

(Essay)
4.8/5
(43)

To take 2 borders and use one as an outer border and the other as an inner border, you would create a

(Multiple Choice)
4.9/5
(42)

What is wrong with the following message to create a BoxLayout for the JPanel jp? Jp)setLayout(new BoxLayout(BoxLayout.X_AXIS));

(Multiple Choice)
4.8/5
(40)

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

(Multiple Choice)
4.8/5
(37)

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.

(Essay)
4.7/5
(41)

Once we have implemented the solution, we are not done with the problem because

(Multiple Choice)
4.8/5
(29)

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.

(True/False)
4.8/5
(30)

It is easier to correct errors found in a program if

(Multiple Choice)
4.8/5
(48)

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( ).

(True/False)
4.8/5
(41)
Showing 1 - 20 of 76
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)