fall2004quiz2 (1)

fall2004quiz2 (1) - 1.00/1.001 Introduction to Computers...

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

View Full Document Right Arrow Icon
1.00/1.001 Quiz 2 1/11 Fall 2004 1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 2 / November 5, 2004 Name: Email Address: TA: Section: Question Points Question 1 / 10 Question 2 / 30 Question 3 / 30 Question 4 / 30 Extra Credit / 10 Total / 100 You have 90 minutes to complete this exam. For coding questions, you do not need to include comments, and you should assume that all necessary files have already been imported. Good luck.
Background image of page 1

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

View Full DocumentRight Arrow Icon
1.00/1.001 Quiz 2 2/11 Fall 2004 Question 1. True / False (10 points) 1. An event source in Swing can have more than one event listener registered with it. TRUE FALSE 2. An event listener in Swing can respond to events from more than one event source. TRUE FALSE 3. A Java class can inherit from more than one class. TRUE FALSE 4. A Java class can implement multiple interfaces. TRUE FALSE 5. Consider the following classes defined in separate Java source files: public class Animal { private int age; } public class Lion extends Animal { public Lion(int a) { age = a; } } The above code would compile. TRUE FALSE
Background image of page 2
1.00/1.001 Quiz 2 3/11 Fall 2004 Question 2. Swing Components and Events (30 points) Read the following code carefully and answer questions. Please assume that all the necessary packages are imported. public class MyApplication Part 1 { private JLabel message; private Font myFont = new Font("SansSerif", Font.BOLD, 18); public MyApplication() { JButton yesButton = new JButton("Yes"); JButton noButton = new JButton("No"); message = new JLabel("IS LEARNING JAVA A FUN EXPERIENCE??"); message.setFont(myFont); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.add(yesButton); buttonPanel.add(noButton); panel.add(message, BorderLayout.CENTER); panel.add(buttonPanel, BorderLayout.SOUTH); Container con = this.getContentPane(); con.add(panel); yesButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // // Implementation hidden // } }); noButton.addActionListener( // Part 3 ); } public static void main(String[] args) { MyApplication app = new MyApplication(); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); app.pack(); app.setVisible(true); } }
Background image of page 3

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

View Full DocumentRight Arrow Icon
1.00/1.001 Quiz 2 4/11 Fall 2004 In the above piece of code, new Java learners are asked a question as shown in Figure 1. Depending on the answer, the application either displays the message of Figure 2 on a
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

fall2004quiz2 (1) - 1.00/1.001 Introduction to Computers...

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

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