prelim3fall2005 - Cornell net id _ Name _ CS 100J Prelim 3...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Cornell net id ____________________ Name ________________________________ 1 CS 100J Prelim 3 15 November 2005 This 90-minute exam has 6 questions (numbered 0. .5) worth a total of 100 points. Spend a few minutes looking at all questions before beginning so that you can see what is expected. Budget your time wisely. Use the back of the pages, if you need more space. We have a stapler at the front of the room, so you can tear the pages apart. Question 0 (2 points). Write your netid and your name, legibly, at the top of each page (Hint: do it now). Question 1 (18 points). (a) Suppose your friend wrote class MyGUI , below, but forgot to write complete specifications for the class and its methods. public class MyGUI extends JFrame { /** The constructor: JFrame with title t and various components */ public MyGUI(String t) { super (t); JPanel p= new JPanel(); p.add( new JButton("yes?")); p.add( new JLabel("fun!!!")); p.add( new JButton("no?")); Box b= new Box(BoxLayout.Y_AXIS); b.add( new JTextField("Programming")); b.add( new JLabel("is")); b.add(p); Container cp= getContentPane(); cp.add(b); pack(); setVisible(true); } } On the next page, draw an approximate representation of the GUI that is created by execution of this new-expression: new MyGUI(“wow!”) If you think a written description of the GUI will help the grader, you can include it, but it is not necessary. 0 ___________ out of 02 1 ___________ out of 18 2 ___________ out of 15 3 ___________ out of 24 4 ___________ out of 20 5 ___________ out of 21 Total ________ out of 100
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Name ________________________________ 2 (b) Below, write a second the constructor, without parameters, for class MyGUI to produce the GUI shown on the right, using just the BorderLayout manager that comes with a JFrame. Write the constructor below. We realize that you may not remember the exact syntax for telling where to place a component; as long as the sense is right, you will receive credit. /** Constructor:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/01/2008 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

Page1 / 7

prelim3fall2005 - Cornell net id _ Name _ CS 100J Prelim 3...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online