COSC II - Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following statements declares Salaried as a subclass of PayType?

public class Salaried extends PayType

Which of the following statements will set a ListView control, puppyListView, to be 300 pixels high and 200 pixels wide?

puppyListView.setPrefSize(200, 300);

What will be displayed after the following statements are executed?String str = "red$green&blue#orange";String[] tokens = str.split("[$&#]");for (String s : tokens) System.out.print(s + " ");

red green blue orange

The Character wrapper class provides numerous methods for:

testing and converting char variables

Which CSS type selector corresponds with the TextField JavaFX class?

text-field

In a try/catch construct, after the catch statement is executed:

the program resumes at the statement that immediately follows the try/catch construct

If a BorderPane region does not contain anything, __________.

the region will not appear in the GUI

In CSS, selector names that begin with a period are called __________ selectors.

type

In Java there are two categories of exceptions which are __________.

unchecked and checked

What does the following code snippet do? Circle myCircle = new Circle(50, 50, 25); TranslateTransition rtrans = new TranslateTransition(new Duration(5000), myCircle);

It creates a circle with center point (50, 50), radius = 25, and duration = 5 seconds.

In the following code, what is missing from ClassA?Line 1 public interface MyInterfaceLine 2 {Line 3 int FIELDA = 55;Line 4 public int methodA(double);Line 5 }Line 6 public class ClassA implements MyInterfaceLine 7 {Line 8 FIELDA = 60;Line 9 public int methodB(double) { }Line 10 }

It does not override methodA.

What does the following statement do? Image puppy = new Image("file:C:\\images\terrier.jpg");

It loads an image file named terrier.jpg which is found in the images folder on the user's C-drive.

In a catch statement, what does the following code do? System.out.println(e.getMessage());

It prints the error message for an exception.

In a multi-catch (introduced in Java 7) the exception types are separated in the catch clause by the __________ symbol.

|

Which of the following creates a custom style class that will allow a Button control to appear with a blue background and yellow text?

} .blue-button { background-color: blue;text-fill: yellow;}

If a subclass constructor does not explicitly call a superclass constructor __________.

Java will automatically call the superclass's default or no-arg constructor just before the code in the subclass's constructor executes

Which of the following statements will display the maximum value that a double can hold?

System.out.println(Double.MAX_VALUE);

Which of the following statements draws the string "Love to animate!" starting at coordinates (200, 50)?

Text myWords = new Text(200.0, 50.0, "Love to animate!");

Assuming that str is declared as follows:String str = "RSTUVWXYZ";What value will be returned from str.charAt(5)?

W

What will be the value of str after the following statements are executed?StringBuilder str = new StringBuilder("We have lived in Chicago, " + "Trenton, and Atlanta.");

We have lived in Chicago, Trenton, and Atlanta.

A file that contains raw binary data is known as a __________.

binary file

On a web page, the __________ specifies what information to display and the __________ specifies how that information should be displayed.

code, CSS

If your code does not handle and exception when it is thrown, __________ prints an error message and crashes the program.

default exception handler

A(n) __________ is an action that takes place in an application, such as the clicking of a button.

event

Programs that operate in a GUI environment must be __________.

event driven

What will be displayed after the following code is executed? boolean matches;String str1 = "The cow jumped over the moon.";String str2 = "moon";matches = str1.endsWith(str2);System.out.println(matches);

false

The try statement may have an optional ________ clause, which must appear after all of the catch clauses.

finally

To replace a ListView control's existing items with a new list of items, use the __________ method.

getItems().setAll()

An exception's default error message can be retrieved using this method.

getMessage()

To retrieve text that a user has typed into a TextField control, you call the __________ method.

getText

Which of the following statements correctly adds a label to the first row and second column of a GridPane object?

gridpane.add(myLabel, 0, 1);

Which of the following import statements is required in order to write an event handler class?

import javafx.event.EventHandler;

Which of the following import statements is required in order to create a BorderPane layout container?

import javafx.scene.layout.BorderPane;

Which of the following import statements must be used in order to use the Color class?

import.javafx.scene.paint.Color;

To display an image in a JavaFX application you must __________.

include both the Image and the ImageView classes

The HBox object's setPadding method takes a(n) __________as its argument.

insets object

Which of the following statements converts a String object variable named str to an int and stores the value in the variable x?

int x = Integer.parseInt(str);

When an exception is thrown __________.

it must be handled by the program or by the default exception handler

What will be displayed after the following code is executed? String str1 = "The quick brown fox jumped over the lazy dog.";String str2 = str1.substring(20, 26);System.out.println(str2);

jumped

Which of the following statements will allow a user to type input into a field of a ComboBox named myComboBox?

myComboBox.setEditable(true);

Assume myView references an ImageView object. In order to preserve the image's aspect ratio (so it does not appear stretched or distorted), you should use which of the following?

myView.setPreserveRatio(true);

In order to leave 15 pixels of space in an HBox container, use which of the following statements?

myhbox.setPadding(new Insets(15));

Which of the following statements correctly specifies two interfaces?

public class ClassA implements Interface1, Interface2

What type of relationship exists between two objects when one object is a specialized version of another object?

"is a"

Given a window that is 640 (width) by 480 (height), which of the following represents the lowest position on the left side?

(0, 479)

Which of the following statements creates an empty TextArea?

TextArea textArea = new TextArea();

To create a TextField control, you use the __________ class which is in the __________ package.

TextField, javafx.scene.control

The __________ control uses a drop-down list as its display.

TextList

What is wrong with the following code?public class ClassB extends ClassA{ public ClassB() { int init = 10; super(40); }}

The call to the method super must be the first statement in the constructor.

A(n) ________ is an object that is generated in memory as the result of an error or an unexpected event.

exception

When you write a method that throws a checked exception, you must __________.

have a throws clause in the method header

To animate a node with the ScaleTransition class, you specify starting and ending __________.

scale factors

How would a stylesheet named javafxstyles.css be applied to a JavaFX application, assuming that scene is the variable that refers to a Scene object?

scene.getStylesheets().add("javafxstyles.css");

What would be the results of executing the following code?StringBuilder str = new StringBuilder("Little Jack Horner ");str.append("sat on the ");str.append("corner");

str reference "Little Jack Horner sat on the corner"

What key word can you use to call a superclass constructor explicitly?

super

Look at the following code. Which line will cause a compiler error?Line 1 public class ClassA Line 2 { Line 3 public ClassA() {}Line 4 public final int method1(int a){ return a;}Line 5 public double method2(int b){ return b;}Line 6 }Line 7 public ClassB extends ClassALine 8 {Line 9 public ClassB(){}Line 10 public int method1(int b){ return b;}Line 11 public double method2(double c){ return c;}Line 12 }

10 cannot override the final method from the class ClassA

What will be the value of loc after the following code is executed?int loc;String str = "The cow jumped over the moon."; loc = str.indexOf("ov");

15

If the data.dat file does not exist, what will happen when the following statement is executed?RandomAccessFile randomFile = new RandomAccessFile("data.dat", "rw");

The file, data.dat, will be created.

What does the following code do, assuming there is a variable that references a Scene object?myScene.getStylesheets().add("sceneStyles.css");

The getStylesheets method returns an object containing the scene's collection of stylesheets and that object's add method adds sceneStyles.css to the collection.

Given the following, which of the statements below is not true? str.insert(8, 32);

The insert will start at position 32.

What is the value of str after the following code has been executed?String str;String sourceStr = "Hey diddle, diddle, the cat and the fiddle";str = sourceStr.substring(12,17);

diddl

To combine several effects, use the Effect class's __________ method.

setInput

All the transition classes inherit a method named __________ which allows you to specify how the animation begins and ends.

setInterpolatpr

What method do you call to register an event handler with a Button control?

setOnAction

To add padding to an HBox you can call the __________ method.

setPadding

The Application class's __________ method is the main entry point for a JavaFX application.

start

The catch clause __________.

starts with the word catch followed by a parameter list in parentheses containing an ExceptionType parameter variable contains code to gracefully handle the exception type listed in the parameter list follows the try clause

What is the output of following code? public class Treeclass { public static void main(String[] args) { Tree Pitch = new Tree(5); Tree Oak = new Tree(10); Tree Apple = new Tree(15); System.out.println( Oak.getNumberofTrees()); class Tree { private static int objectCount=0; private int NumberofTrees; public Tree(int num ) { objectCount++; NumberofTrees = num; } int getObjectCount() { return objectCount;} int getNumberofTrees(){ return NumberofTrees; }}

10

What does the following code snippet do when the animation is played, given that imageView has been created? FadeTransition ftrans = new FadeTransition (new Duration(5000), imageView); ftrans.setFromValue(1.0);ftrans.setToValue(0.5);ftrans.play():

The image will be completely opaque when displayed and will decrease to 50% opacity over the five seconds of the animation.

Given the following styles, what size will the text of the label be? .root { -fx- font-size: 12pt; } .label { -fx- font-size: 18pt; }

18 pts

What will be the value of position after the following code is executed?int position;String str = "The cow jumped over the moon.";position = str.lastIndexOf("ov", 14);

-1

To apply specific styles to all of the nodes in a scene, use the __________ selector.

.root

What will the following code display?String input = "99#7";int number;try{ number = Integer.parseInt(input);}catch(NumberFormatException ex){ number = 0;}catch(RuntimeException ex){ number = 1;}catch(Exception ex){ number = -1;}System.out.println(number);

0

What will be the tokens for the following code?String str = "123-456-789_123";String[] tokens = str.split("-");

123 456 789_123

What is the output of following code? public class Treeclass { public static void main(String[] args) { Tree Pitch = new Tree(5); Tree Oak = new Tree(10); Tree Apple = new Tree(15); System.out.println( Oak.getObjectCount()); class Tree { private static int objectCount=0; private int NumberofTrees; public Tree(int num ) { objectCount++; NumberofTrees = num; } int getObjectCount() { return objectCount;} int getNumberofTrees(){ return NumberofTrees; }}

3

If, within one try statement you want to have catch clauses of the following types, in which order should they appear in your program: (1) Exception(2) IllegalArgumentException(3) NumberFormatException(4) Throwable(5) RuntimeException

3, 2, 5, 1, 4

In the following code, assume that inputFile references a Scanner object that has been successfully used to open a file:double totalIncome = 0.0;while (inputFile.hasNext()){try{totalIncome += inputFile.nextDouble();}catch(InputMismatchException e){System.out.println("Non-numeric data encountered " +"in the file.");inputFile.nextLine();}finally{totalIncome = 35.5;}}

35.5

What will be printed after the following code is executed?String str = "abc456";int m = 0;while ( m < 6 ) { if (!Character.isLetter(str.charAt(m))) System.out.print( Character.toUpperCase(str.charAt(m))); m++;}

456

For the following code, how many times would the for loop execute?String str = "1,2,3,4,5,6,7,8,9";String[] tokens = str.split(",");for (String s : tokens) System.out.println(s);

9

What happens when the following code is executed?ComboBox<string> myComboBox = new ComboBox<>();myComboBox.getItems().addAll(5, 10, 15, 20);

A compiler error will occur.

What will be printed after the following code is executed?String str = "abc456";int m = 0;while ( m < 6 ){ if (Character.isLetter(str.charAt(m))) System.out.print(Character.toUpperCase(str.charAt(m))); m++;}

ABC

The __________ arc type causes a straight line to be drawn from one endpoint of the arc to the other endpoint.

ArcType.CHORD

Which of the following will create a CheckBox that displays pizza and shows up as selected?

CheckBox checkOne = new CheckBox("pizza");checkOne.setSelected(true);

Which of the following creates a blue circle centered at X = 50, Y = 50 with a radius of 50?

Circle blueCircle = new Circle(50, 50, 50); blueCircle.setFill(Color.BLUE);

In the following statement, which is the subclass?public class ClassA extends ClassB implements ClassC

Class A

In the following statement, which is the superclass (ClassA, ClassB, or ClassC)?public class ClassA extends ClassB implements ClassC

Class B

In the following statement, which is the interface?public class ClassA extends ClassB implements ClassC

Class C

Given the following code, which statement is true?public class ClassB implements ClassA{ }

ClassB must override each method in ClassA

Which effect class do you use to increase an image's brightness?

ColorAdjust

The __________ class specifies the amount of time an animation should last.

Duration

All of the exceptions you will handle are instances of classes that extend the __________ class.

Exception

To create an animation in which a node fades in or out over a period of time, use the __________ class.

FadeTransition

To read data from a binary file you create objects from the following classes:

FileInputStream and DataInputStream

To write data to a binary file you create objects from the following classes:

FileOutputStream and DataOutputStream

The __________ layout container arranges its contents with columns and rows.

GridLayout

The __________ layout container arranges the contents into cells, similar to a spreadsheet.

GridPane

Any time a user presses a key, a __________ event occurs.

KEY_PRESSED

Look at the following code.Line 1 public class ClassALine 2 {Line 3 public ClassA() {}Line 4 public void method1(){}Line 5 }Line 6 public class ClassB extends ClassALine 7 {Line 8 public ClassB(){}Line 9 public void method1(){}Line 10 }Line 11 public class ClassC extends ClassBLine 12 {Line 13 public ClassC(){}Line 14 public void method1(){}Line 15 }Which method1 will be executed as a result of the following statements?ClassA item1 = new ClassC();item1.method1();

Line 14

Which of the following code snippets creates a Line and uses a RotateTransition object to animate it for seven seconds?

Line myLine = new Line(25, 50, 100, 50); RotateTransition rtrans = new RotateTransition(new Duration(7000), myLine);

The control that displays a list of items and allows the user to select an item from the list is the __________ control.

ListView

Which of the following statements converts an int variable named number to a string and stores the value in the String object variable named str?

String str = Integer.toString(number);

Which mouse event occurs when the user presses and releases the mouse button?

MOUSE_CLICKED

The __________ class is used to create a menu bar.

MenuBar

Which of the following is a subclass of Node?

Neither of these; Media Media Player

The type of control normally used when you want the user to only be allowed to select one option from several possible options is the __________.

RadioButton

Which class creates an animation in which a node rotates?

RotateTransition

Which transition class causes a node to become larger or smaller?

ScaleTransition

Which of the following statements creates a Slider with a range of 1 to 20 with a starting value of 1?

Slider slider = new Slider(1.0, 20.0, 1.0);

Assuming three ImageView objects named puppy, kitten, and bunny have been created, what does the following statement do?HBox hbox = new HBox(5, puppy, kitten, bunny);

There will be five pixels of space between the controls horizontally in the container.

If you have two RadioButtons (dogRadio and catRadio), how should you code them to create a mutually exclusive relationship?

ToggleGroup radioGroup = new ToggleGroup();dogRadio.setToggleGroup(radioGroup);catRadio.setToggleGroup(radioGroup):

The __________ class is used to move a node from one position on the screen to another.

TranslateTransition

When you are writing a program with String objects that may have unwanted spaces at the beginning or end of the strings, use this method to delete them.

Trim

To serialize an object and write it to the file, use the __________ method of the ObjectOutputStream class.

WriteObject

What will be printed after the following code is executed?String str = "abc456";int m = 0;while ( m < 6 ){ if (Character.isLetter(str.charAt(m))) System.out.print( str.charAt(m)); m++;}

abc

When an "is a" relationship exists between objects, it means that the specialized object has:

all the characteristics of the general object, plus additional characteristics

All fields declared in an interface:

are final and static

If you set a scene's size to a width and height that is smaller than the width and height of the image to be displayed ___________.

only part of the image will be displayed

A subclass may call an overridden superclass method by:

prefixing its name with the super key word and a dot (.)

A __________ member's access is somewhere between public and private

protected


संबंधित स्टडी सेट्स

7G1 Math Exam Review First Semester

View Set

HSC4501: EXAM 3 STUDY GUIDE, iCLICKERS, AND HW ASSIGNMENTS

View Set

Properties of Numbers & Fractions

View Set

Sherpath - Chapter 21: Managing Patient Care

View Set