Assignment questions

¡Supera tus tareas y exámenes ahora con Quizwiz!

Q22: The boolean values can be displayed with the ________ format specifier.

%b

Q16: The format specifier ________ is a place-holder for an int value?

%d

Q13: Which flag in a format specifier indicates that values with fewer digits than the field width should begin with a leading 0?

0... %09.3f

Consider the code segment below: int xValues[] = { 100, 150, 200, 100 }; int yValues[] = { 30, 130, 30, 30 }; g.drawPolyline( xValues, yValues, 4 );

= A triangle

Q17: How many significant digits does a double variable have?

15

JColorChooser does not allow you to pick...

Gradient, Cycle, or Brightness

Q5: To draw on an applet, the programmer must access the ________ object in the applet's paint method.

Graphics

Q10: Which method should be used to draw a line of text on an applet?

Graphics method drawString

a. An interface describes a set of methods that can be called on an object, providing a default implementation for the methods.

False

b. The term "bit" is short for "byte digit."

False

d. Data maintained in files is often called transient data.

False

Class Formatter contains method printf, which enables formatted data to be output to the screen or to a file.

False, it has method format

Q16: Which of the following exceptions is a checked exception?

IOException

Q4: Which of the following classes is not used for file input?

Formatter

An advantage of inheritance is...

Objects o a subclass can be treated like objects of their superclass.

how can you initialize a new Color c?

A. Color c = new Color( 0, 255, 0 ); B. Color c = new Color( 0.0f, 1.0f, 0.0f );

Q28: The identifiers in an enumeration ________.

A. class, block

The control variable of a counter-controlled loop should be declared as ?

int

b. File name = new File( "files.txt" );

is not a valid pathway

Inheritanace is a...

is-a relationship

Q8: It is a UML convention to denote the name of an abstract class in:

italics

Q48: Selecting a JList item generates:

listSelectionEvent

Q24: Which of the following is NOT a way that repetition is implemented in Java programs?

loop statement

Q9: What is the default value of a reference?

null

Q9: Overriding a method differs from overloading a method because:

overriden methods have the same signature

Q6: Using the protected keyword gives a member:

package access

Q5: How do methods setIn, setOut and setErr affect the standard input, output and error streams?

They redirect the standard input,output, and error streams

Q1: Sending a message to an object means that:

You call a method and you access a variable.

Q6: Which of the following methods is not in the Math class?

parseInt

Q6: A(n) _____ class cannot be instantiated.

abstract

Q6: When should a program explicitly use the this reference?

accessing a field that is shadowed by a local variable.

Q15: A JLabel can be attached to a JFrame using method:

add

Q11: In Java, after an exception is handled, control resumes _______ . This is known as the _______ model of exception handling.

after the last catch block (or the finally block, if there is one), termination

Q14: Which statement is true when a superclass has protected instance variables?

all of the above.

The browser that executes an applet is generally known as the

applet container

Q12: When implementing a method, use the class's set and get methods to access the class's ________ data.

private

Q7: Superclass methods with this level of access cannot be called from subclasses.

private

Q6: Which statement is false?

b. Activity diagrams normally show the Java code that implements the activity.

Which of the following is not included in an activity diagram for a control structure?

b. Attribute

Q25: Sentinel-controlled repetition is also known as:

b. Indefinite repetition

Q12: _____ Provides the basic attributes and behaviors of a window—a title bar at the top of the window, and buttons to minimize, maximize and close the window.

b. JFrame.

Every class except ____ extends an existing class.

b. Object.

Q8: Which statement prints the floating-point value 123.456 right justified with a field width of 10?

b. System.out.printf( "%10.3d", 123.456 );

Q9: Which statement prints the floating-point value 123.456 right justified with a field width of 10?

b. System.out.printf( "%10.3d", 123.456 );

Q11: Which of the following statement displays Hello World?

b. System.out.printf( "%s %s", "Hello", "World" );

Q19: A general path is:

b. a shape constructed from straight lines and complex curves.

Q12: Which of the following is the superclass constructor call syntax?

b. keyword super, followed by a set of parentheses containing the superclass constructor arguments.

What will create a polygon that is a square?

b. poly2.addPoint( 200, 130 ); poly2.addPoint( 200, 30 );

Q17: The Graphics2D method(s) that determine(s) the color and texture for the shape to display is/are:

b. setPaint

Q26: The first statement in every paintComponent method should be a call to ________.

b. super.paintComponent.

: Which statement correctly passes array items to method takeArray? Array items contains 10 elements.

b. takeArray( items ).

Q17: If the catch-or-declare requirement for a checked exception is not satisfied:

b. the compiler will issue an error message indicating that the exception must be caught or declared.

Q14: Records in a sequential file are not usually updated in place. Instead:

b. the entire file is rewritten

24: Which of the following terms is NOT used to refer to a sentinel value that breaks out of a while loop?

break out value

Q13: Which of the following is not true of a JLabel?

c. A JLabel can display text and a button.

Q3: For which of the following would polymorphism not provide a clean solution?

c. A program to compute a 5% savings account interest for a variety of clients.

Q12: Which of the following statements about arcs is not true?

c. Arcs that sweep clockwise are measured in positive degrees.

Q7: Which of the following will not produce an error when trying to load and run a program with the appletviewer?

c. Creating an applet that is less than 640 pixels by 480 pixels.

The Java statement: g.fillOval( 290, 100, 90, 55 );

c. Draws a filled oval bounded by a rectangle with its upper left corner at coordinates x=290, y=100, with width=90 and height=55.

Q15: Which two Java primitive types store floating-point numbers?

c. Float and Double

Q30: Which of the following statements describes block scope?

c. It begins at the identifier's declaration and ends at the terminating right brace (}).

Q5: The JOptionPane constant used to display an icon prompting the user for input is:

c. JOptionPane.QUESTION_MESSAGE.

What's true about syntax and logic errors?

c. Syntax errors are caught by the compiler. Logic errors have effects at execution time.

Which case of the following would warrant using the boolean logical inclusive OR (|) rather than the conditional OR (||)?

c. Testing if at least one of two conditions is true when the right operand has a required side effect.

Q15: Which of the following statements about the break statement is false?

c. The break statement, when executed in a while, for or do...while, skips the remaining statements in the loop body and proceeds with the next iteration of the loop.

Q12: Which of the following is not true about the conditional operator ( ?: )?

c. The second operand is the result value if the condition evaluates to false.

what should usually be private?

c. Variables (or fields).

Which formatting flag indicates that the floating-point values should be output with a thousands separator?

c. comma (,).

What is the differences between a float and a double?

c. double variables store numbers with larger magnitude and finer detail.

The Java statement: g.draw3DRect( 290, 100, 90, 55, true );

c. draws a rectangle that appears to be raised (the bottom and right edges of the rectangle are slightly darker than the rectangle).

Q16: Failure to prefix the superclass method name with the keyword super and a dot (.) separator when referencing the superclass's method causes a(n) ________.

c. infinite recursion

Q3: Which of the following methods is not in the Math class?

c. parseInt.

Q10: Which of the following could be used to declare abstract method method1 in abstract class Class1

c. public abstract int method1();

Q5: Which of the following is an action-state symbol?

c. rectangles with left and right sides replaced with arcs curving outward.

Q10: When an argument is passed by reference:

c. the called method can access the argument's value in the caller directly and modify that data.

Q23: When an argument is passed by reference:

c. the called method can access the argument's value in the caller directly and modify that data.

Q12: When an object is concatenated with a String:

c. the object's toString method is implicitly called to obtain the String representation of the object.

Q25: Method drawOval's arguments specify ________.

c. the position and size of the bounding rectangle for the oval.

Which of the following answers does not complete the sentence correctly? An anonymous inner class ____________ .

cannot be declared private

Q5: Which statement best describes the relationship between superclass and subclass types?

d. A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

Q24: Which of the following most completely describes the steps for setting up event handling for a GUI component?

d. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.

Q6: Which of the following is not true for a JTextField?

d. Displays a list of fields.

Q10: Which statement regarding Java files is false?

d. Records in a Java sequential file are stored in order by record key.

Q24: What kind of application tests a class by creating an object of that class and calling the class's methods?

d. Test harness.

Q39: Which of the following is not true of an arc?

d. The fillArc method draws an oval, with the section that is an arc filled in.

Q9: Which method is called by the applet container when the applet is being removed from memory.

destroy

Q7: Relative paths normally start from which directory?

directory in which the application began executing

Q35: An argument type followed by a(n) ______ in a method's parameter list indicates that the method receives a variable number of arguments

ellipsis (...).

A static method can call instance methods directly.

false

A superclass object is a subclass object...

false

Is a container a jpanel?

false

Objects are marked for garbage collection by method finalize.

false

a. A BufferedImage object uses the image stored in its associated TexturePaint object as the fill texture for a filled-in shape.

false

a.The compiler always creates a default constructor for a class.

false

c. The finally block and try block can appear in any order.

false

c. c. An enum constructor cannot be overloaded.

false

c. c. Clients are usually involved in a class's implementation.

false

Q40: Filled rectangles and filled circles are drawn using Graphics method ________ and ________.

fillrect, filloval

Q5: Filled rectangles and filled circles are drawn using Graphics method ________ and ________.

fillrect, filloval

Q17: enum types are implicitly ________ and enum constants are implicitly ________.

final , static

Q22: Which method is not related to multithreading?

finalize

Q7: Method getFont of class Graphics returns:

font Object representing the current font

Q19: Assume array items contains the values 0, 2, 4, 6 and 8. Which of the following set of statements uses the enhanced for loop to display each value in array items?

for ( int i : items ) System.out.prinf( "%d\n", i ); The i is the value.

Q13: Which of the following statements draws an arc that sweeps from the top of an oval to the left-most edge?

g.drawArc( 200, 100, 100, 50, 90, 90 );

Q8: Which method is called once by the applet container when an applet is loaded for execution.

init

What are the three applet methods called in sequence when a container loads an applet?

init, start, paint

Polymorphism enables you to...

program in the general

Q1: The _________ of a class are also called the public services or the public interface that the class provides to its clients.

public methods

The _________ of a class are also called the public services or the public interface that the class provides to its clients.

public methods

: The Java platform uses the _________ to prevent code that is downloaded to your local computer from accessing local system resources, such as files.

sandbox security model

Q24: Which method changes the text the label displays?

setText

Q16: Which method sets the text that is displayed when the user hovers over a JLabel?

settooltiptext

Q20: The default implementation of method clone of Object performs a ________.

shallow copy.

Q3: Which of the following is not a benefit of "goto-less programming"?

shorter

Q3: Which of the following is the method used to display a dialog box to gather input?

showInputDialogue

A jbutton is an abstract button...

true

Method exists of class File returns true if the name specified as the argument to the File constructor is a file or directory in the specified path.

true

Is jbutton stateless?

true.

graphics object is...

Abstract, manages a graphics context, and is the argument to paintcomponent method

Q7: Java uses class ________ to represent colors using their RGB values.

colo

Q39: Java uses class ________ to represent colors using their RGB values.

color

Q7: Non-abstract classes are called:

concrete classes

Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?

.super

: When an applet container encounters an HTML file that specifies an applet to execute, the applet container automatically loads ________ of the applet from the same directory as that of the HTML file

.class

Q14: Which of the following can be used in the expression after keyword case?

A character constant. a constant

Counter- controlled repetition requires...

A control variable, an increment or decrement, a condition that tests for the final value.

Q5: Calling a method of another object requires which item?

A dot separator

How do you initialize a font?

B. Font f = new Font( "Serif", Font.Bold + Font.Italic, 19 );

Q18: Which of the following primitive types is never promoted to another type?

Double and Boolean

Sentinel-Controlled repetitions is also known as...

Indefinite repetition

Q44: The setMaximumRowCount method is used for:

Jcombobox

Q11: What is the default initial value of a String?

Null

Q17: When a subclass constructor calls its superclass constructor, what happens if the superclass's constructor does not assign a value to an instance variable?

Program compiles and runs because the variables are initialized to default values

Q11: In recursive backtracking, if one set of recursive calls does not result in a solution to the problem, what happens?

Program returns to a previous decision point and makes a different decision.

Q8: Which of the following is not true of Swing GUI components?

Swing components are less portable but more flexible than the original Java GUI components from package java.awt.

Q11: What happens when this is used in a constructor's body to call another constructor of the same class if that call is not the first statement in the constructor?

Syntax error

Q15: Using public set methods provides data integrity if:

The instance variables are private and the method performs validity checking.

A container event is a component event...

True

Q9: Which of the following is not true of heavyweight components?

a. AWT components are not heavyweight components.

Q19: In an activity diagram, the merge symbol has the same shape as what other symbol?

a. Decision symbol

Q20: Counter-controlled repetition is also known as:

a. Definite repetition

Q10: A decision symbol in an activity diagram takes the shape of a ________.

a. Diamond.

Q9: Which of the following is not an application of a File object?

a. Open or edit a file.

Q15: The empty statement is denoted with what symbol?

a. Semicolon;

Q11: Which of the following statements about abstract superclasses is true?

a. abstract superclasses may contain data.

Q20: After a finally block has finished executing (and there are no exceptions to be handled):

a. control proceeds to the first statement after the finally block

Q20: GeneralPath method lineTo

a. draws a line from the previous point in the GeneralPath object to the current point.

Q11: To draw a single black line from (0, 15) to (20, 25), call the method _________ in the paint method.

a. g.drawLine( 0, 15, 20, 25 );

Q8: Which of the following is correct for font metrics?

a. height = descent + ascent + leading.

Q36: Which command below runs TestProgram, and passes in the values files.txt and 3?

a. java TestProgram files.txt 3.

Which of the following expressions creates a JLabel that displays the text "Here is what I look like!" The JLabel should display Icon object face, and the JLabel's contents should be left aligned.

a. new JLabel( "Here is what I look like!", face, SwingConstants.LEFT )

Q11: Some common lightweight component features supported by JComponent include:

a. support for user-interface localization.

Q3: Which of the following is arranged in increasing size order?

bit, field, record, file

Q15: All exception classes inherit, either directly or indirectly, from:

class Throwable.

Q4: Which of the following is not a control structure:

d.action structure

Q11: When all the contents of a file are truncated, this means that:

data is discarded

Q4: Polymorphism allows for specifics to be dealt with during:

execution

Q18: Which expression returns the location of a file as a URL?

getResource

Q16: Composition is sometimes referred to as a(n) ________.

has - a

Q23: Class ________ represents an image that can be displayed on a JLabel.

imageicon

Q9: If the superclass contains only abstract method declarations, the superclass is used for:

interface inheritance

Set methods are also commonly called ________ methods and get methods are also commonly called ________ methods

mutator, accessor

What does the following statement do? Scanner scanner = new Scanner( new File( "test.txt" ) );

opens a text file for input

Every java applet is composed of at least one...

public class declaration

An applet can be restarted by using what?

reload command from applet menu

Q37: Method calls cannot be distinguished by ________.

return type

Declaring main as ________ allows the JVM to invoke main without creating an instance of the class.

static

Q25: A final field should also be declared ________ if it is initialized in its declaration.

static

What is the layout of a switch statement?

switch( int i ) { case 1: System.out.println( 1 ); case 2:

Q5: Math static method random generates a random double value in the range from 0.0

up to but not including 1.0

Q19: Which method returns an array of the enum's constants?

values


Conjuntos de estudio relacionados

Managerial Accounting Test 1 Chapter 1

View Set

Recapitulación: 2-Vacaciones en París

View Set

chapter 5: field underwriting procedures

View Set

EAQ #1 F & E, Acid-Base, Cancer, HIV/AIDS, Hematology

View Set