Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CS 1102 Graded Quiz Chapter 4-6 with Answers- University of the People

Rating
-
Sold
-
Pages
18
Grade
A
Uploaded on
15-08-2022
Written in
2022/2023

CS 1102 Graded Quiz Chapter 4-6 with Answers- University of the People/CS 1102 Graded Quiz Chapter 4-6 with Answers- University of the People/CS 1102 Graded Quiz Chapter 4-6 with Answers- University of the People/CS 1102 Graded Quiz Chapter 4-6 with Answers- University of the People/CS 1102 Graded Quiz Chapter 4-6 with Answers- University of the People

Show more Read less
Institution
Course

Content preview

Question 1
Incorrect
Mark 0.00 out of 1.00




Flag question
Question text
Consider the following Java program. Which line implements an interface method?

import java.awt.event.*;
import javax.swing.*;
public class MouseWhisperer extends JFrame implements MouseListener
{
MouseWhisperer() {
super("COME CLOSER");
setSize(300,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addMouseListener(this);
setVisible(true);
}
public void mouseClicked(MouseEvent e) { setTitle("OUCH"); }
public void mousePressed(MouseEvent e) { setTitle("LET GO"); }
public void mouseReleased(MouseEvent e) { setTitle("WHEW"); }
public void mouseEntered(MouseEvent e) { setTitle("I SEE YOU");
}
public void mouseExited(MouseEvent e) { setTitle("COME
CLOSER"); }
public static void main(String[] args) { new
MouseWhisperer(); }
}

Select one:
a. public void mouseEntered(MouseEvent e) { setTitle("I SEE YOU"); }
b. addMouseListener(this);
c. super("COME CLOSER");
d. public class MouseWhisperer extends JFrame implements MouseListener {


e. public static void main(String[] args) { new MouseWhisperer(); }

Feedback
Your answer is incorrect.
See Section 6.3.2.

,The correct answer is: public void mouseEntered(MouseEvent e) { setTitle("I SEE YOU"); }

Question 2
Correct
Mark 1.00 out of 1.00




Flag question
Question text
What is the output of the following Java program?
public class Food {
static int count;
private String flavor = "sweet";
Food(String s) { flavor = s; }
void setFlavor(String s) { flavor = s; }
String getFlavor() { return flavor; }
static public void main(String[] args) {
Food pepper = new Food("spicy");
Food chile = pepper;
pepper.setFlavor("smoky");
System.out.println(chile.getFlavor());
}
}

Select one:
a. spicy
b. false
c. true
d. smoky


e. sweet

Feedback
Your answer is correct.
Setting "chile = pepper" causes the two object variables to refer to the same single object. Because
"chile" and "pepper" refer to the same object, the flavor set by "pepper.setFlavor" is seen by
"chile.getFlavor". See Section 5.1.2 of Eck (2014).
The correct answer is: smoky

Question 3
Incorrect
Mark 0.00 out of 1.00

, Flag question
Question text
Consider the following Java program. Which one of the following does NOT describe
"MouseWhisperer"?

import java.awt.event.*;
import javax.swing.*;
public class MouseWhisperer extends JFrame implements MouseListener
{
MouseWhisperer() {
super("COME CLOSER");
setSize(300,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addMouseListener(this);
setVisible(true);
}
public void mouseClicked(MouseEvent e) { setTitle("OUCH"); }
public void mousePressed(MouseEvent e) { setTitle("LET GO"); }
public void mouseReleased(MouseEvent e) { setTitle("WHEW"); }
public void mouseEntered(MouseEvent e) { setTitle("I SEE YOU");
}
public void mouseExited(MouseEvent e) { setTitle("COME
CLOSER"); }
public static void main(String[] args) { new
MouseWhisperer(); }
}

Select one:
a. A "MouseWhisperer" object can be assigned to a "JFrame" variable.


b. A "MouseWhisperer" object listens for action events.
c. A "MouseWhisperer" object responds to mouse movement.
d. A "MouseWhisperer" object responds to mouse clicks.
e. The "MouseWhisperer" class can be run as a program.

Feedback
Your answer is incorrect.
A "MouseWhisperer" object responds to mouse events ("addMouseListener"), not action events. See
Sections 6.1.3 and 6.3.1.

Written for

Course

Document information

Uploaded on
August 15, 2022
Number of pages
18
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$18.48
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Timeless2024 Chamberlain College Nursing
Follow You need to be logged in order to follow users or courses
Sold
3668
Member since
6 year
Number of followers
3135
Documents
2172
Last sold
6 days ago
Email/DM Me for the LATEST REVISED Exams, Study Guides, Assignments, Quizzes etc. @

Number one Stop Shop for Study Guides, Exams, Assignments, Test Banks etc 2023/2024

3.9

683 reviews

5
342
4
127
3
105
2
41
1
68

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions