0% found this document useful (0 votes)
3 views10 pages

During Program Development Software Requirements Specify

The document contains a series of questions and answers related to Java programming, covering topics such as object-oriented design, inheritance, data types, and control structures. Each chapter includes multiple-choice questions and coding exercises aimed at reinforcing key concepts in Java. The content is structured to aid in learning and understanding Java programming principles.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

During Program Development Software Requirements Specify

The document contains a series of questions and answers related to Java programming, covering topics such as object-oriented design, inheritance, data types, and control structures. Each chapter includes multiple-choice questions and coding exercises aimed at reinforcing key concepts in Java. The content is structured to aid in learning and understanding Java programming principles.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 7: Object-Oriented Design

Q1) During program development, software requirements specify


A) how the program will accomplish the task
B) what the task is that the program must perform
C) how to divide the task into subtasks
D) how to test the program when it is done
E) all of the above

See Q1 Verified Answer

Q2) During program development, software requirements specify


A) how the program will accomplish the task
B) what the task is that the program must perform
C) how to divide the task into subtasks
D) how to test the program when it is done
E) all of the above

See Q2 Verified Answer

Q3) All objects implement Comparable.

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter
Chapter 1: Introduction

Q1) A Java program is best classified as


A) hardware
B) software
C) storage
D) processor
E) input

See Q1 Verified Answer

Q2) Name five of the fundamental terms which encompass object-oriented


programming.

See Q2 Verified Answer

Q3) Inheritance is a form of software reuse.

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 2
Chapter 3: Using Classes and Objects

Q1) Rewrite the following five assignment statements into a single statement using prefix
and postfix increment and decrement operators as necessary. Assume all variables are
int variables.
x = y + 1;
y = y + 1;
z = z - 1;
x = x - z;
x = x + 1;

See Q1 Verified Answer

Q2) What happens if you attempt to use a variable before it has been initialized?
A) A syntax error may be generated by the compiler
B) A runtime error may occur during execution
C) A "garbage" or "uninitialized" value will be used in the computation
D) A value of zero is used if a variable has not been initialized
E) Answers A and B are correct

See Q2 Verified Answer

Q3) [Link]("123" + 4) will display the value 127.

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 3
Chapter 2: Data and Expressions

Q1) If x is the String "Hi There", then [Link]( ).toLowerCase( ); will return the
original version of x.

See Q1 Verified Answer

Q2) If the String major = "Computer Science", what is returned by [Link](1)?


A) 'C'
B) 'o'
C) 'm'
D) "C"
E) "Computer"

See Q2 Verified Answer

Q3) Write the paint method for an applet so that it contains 4 concentric circles (each
circle is inside the previous circle), where the largest circle is bounded by a 400x400 box
and the smallest is bounded by a 100x100 box. Each circle is centered on an applet that is
400x400. Make each circle a different color of your choice.

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 4
Chapter 9: Inheritance

Q1) The instruction super( ); does which of the following?


A) calls the method super as defined in the current class
B) calls the method super as defined in the current class'parent class
C) calls the method super as defined in [Link]
D) calls the constructor as defined in the current class
E) calls the constructor as defined in the current class'parent class

See Q1 Verified Answer

Q2) Interface classes cannot be extended but classes that implement interfaces can be
extended.

See Q2 Verified Answer

Q3) An Applet implements MouseMotionListener and is 600x600 in size. Write a


mouseMoved method so that if the mouse is moved into the upper left hand quadrant of
the Applet, the entire applet turns blue, if the mouse is moved into the upper right hand
quadrant of the Applet, the entire applet turns yellow, if the mouse is moved into the
lower left hand quadrant of the Applet, the entire applet turns green, and if the mouse is
moved into the lower right hand quadrant of the Applet, the entire applet turns red.

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 5
Chapter 8: Arrays

Q1) The Mouse Motion Events include


A) mousePressed, mouseReleased, mouseClicked, mouseEntered, mouseExited
B) mousePressed, mouseReleased, mouseClicked, mouseEntered, mouseExited,
mouseMoved, mouseDragged
C) mousePressed, mouseReleased, mouseClicked, mouseMoved, mouseDragged
D) mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseDragged
E) mouseMoved, mouseDragged

See Q1 Verified Answer

Q2) Implement an ItemListener so that a new value is output by the second JLabel every
time a JCheckBox is clicked on.

See Q2 Verified Answer

Q3) Write code fragment to swap the two Strings stored by variables a and b.

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 6
Chapter 6: More Conditionals and Loops

Q1) Write a "query-controlled" loop that will continue to input int values from the user,
adding each to the int value sum, and then ask if the user has another value to input,
until the user says that there are no more values. Assume that [Link] has been
imported.

See Q1 Verified Answer

Q2) Show the output that would occur from the following code, including proper spacing.
for (j = 0; j < 5; j++)
{
for (k = 0; k < 5; k++)
if (j!=k)
[Link](' ');
else
[Link]('*');
[Link]( );
}

See Q2 Verified Answer

Q3) Rewrite the following if-else statement using a conditional operator.


if (x > y) z = x; else z = y;

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 7
Chapter 4: Writing Classes

Q1) Defining formal parameters requires including each parameters type.

See Q1 Verified Answer

Q2) Java methods can return only primitive types (int, double, float, char, boolean, etc).

See Q2 Verified Answer

Q3) A constructor may contain a return statement so long as no value (or expression) is
returned.

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 8
Chapter 13: Collections

Q1) Two abstract data types are the ordered list and the unordered list. Explain how
these two ADTs are similar and how they will differ. To answer this question, assume that
you do not know how they are implemented (that is, whether they are implemented
using an array or a linked list).

See Q1 Verified Answer

Q2) What is an ADT (an Abstract Data Type) and why are they considered to be
"abstract?
"

See Q2 Verified Answer

Q3) Which of the following lists of commands is used to see the top item of a Stack
without removing it from the Stack?
A) push
B) pop
C) peak
D) see
E) top

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 9
Chapter 5: Conditionals and Loops

Q1) In Java, the symbol "=" and the symbol "==" are used synonymously
(interchangeably).

See Q1 Verified Answer

Q2) As in the other members of the C family of languages (C, C++, C#), Java interprets a
zero value as false and a non-zero value as True.

See Q2 Verified Answer

Q3) The following code has a syntax error immediately before the word else. What is the
error and why does it arise?
Fix the code so that this statement is a legal if-else statement.
if (x < 0) ; x++;
else x--;

See Q3 Verified Answer

Click here! To get all questions and flashcards with answers for this chapter

Page 10

You might also like