quizsolution

quizsolution - 1.00/1.001 Introduction to Computers and...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 2 / November 10, 2005 Name: Email Address: TA: Section: 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. Question Points Question 1 / 24 Question 2 / 30 Question 3 / 20 Question 4 / 16 Question 5 / 10 Total / 100 HW1 HW2 HW3 HW4 HW5 HW6 Q1 Question 1 True/False 1) A class may extend one or more classes. TRUE FALSE 2) A class may implement one or more interfaces. TRUE FALSE. The following code fragment is associated with problems 3) and 4) public abstract class SomeClass{ public SomeClass(){ //implementation not shown } //remainder of implementation not shown } public interface SomeInterface{ //declarations not shown } 3) The statement SomeClass c = new SomeClass(); will not compile in Java. TRUE FALSE 4) The statement SomeInterface i = new SomeInterface(); will not compile in Java. TRUE FALSE 5) Events in Java are objects that are created by Event Sources (such as JButtons, JPanels, and other Components). TRUE FALSE 6) Each Event Listener (for example, a class that implements the ActionListener interface) can only register to receive Events from one Event Source (for example, one JButton). T R U E FALSE 7) Multiple different Event Listeners can register to receive Events from the same Event Source. T R U E F A L S E 8) You want to extend JPanel to make a new class that draws a smiley face in the middle of the JPanel. Where should you put your drawing code? Circle all that choices that apply: a) the repaint() method b) the constructor c) the paintComponent(Graphics g) method d) none of the above Question 2 - Inheritance and Interfaces QuizClass , QuizClass2 and QuizInterface are all in the same package. However, QuizClass and QuizInterface are incomplete. Read and complete the code fragments below for QuizClass and QuizInterface . //QuizClass.java public abstract class QuizClass{ protected double var1; public static final int CONS1=10; private float var2; public QuizClass(double var1, float var2){ /*Part 1: complete the constructor, initializing the var1 and var2 data members*/ this.var1 = var1; this.var2 = var2; } public double getVar1(){ return var1; } public float getVar2(){ return var2; } /*Part 2: declare an abstract calc1() method that...
View Full Document

Page1 / 12

quizsolution - 1.00/1.001 Introduction to Computers and...

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

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