COP 2800 FINAL EXAM

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

What will be displayed after the following statements are executed? int hours = 30; double pay, payRate = 10.00; pay = hours <= 40 ? hours*payRate : hours*payrate*2.0; system.out.println(pay);

300.0

What is the result of the following expression? 10 + 5 * 3 - 20

5

A method is called from the main method for the first time. It then calls itself seven times. What is the depth of recursion?

7

What is the result of the following expression? 17 % 3 * 2 - 12 + 15 17 % 3 = 2 2 * 2 -12 + 15 4-12+15= 7

7

There are ________ bits in a byte.

8

What is the value of scores[2][3] in the following array? int[][] scores = { {88, 80, 79, 92} {75, 84, 93, 80} {98, 95, 92, 94} {91, 84, 88, 96}};

94

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

HTML, CSS

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

It prints the error message for an exception.

What does <String> specify in the following statement? ArrayList<String> nameList = new ArrayList<String>();

It specifies that only String objects may be stored in the ArrayList object.

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 draws the string "Love to animate!" starting at coordinates (200, 50)?

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

What happens if a program does not handle an unchecked exception?

The program is halted and the default exception handler handles the exception.

When a method's type is an object, what is actually returned by the calling program?

a reference to an object of that class

A computer program is

a set of instructions that allow the computer to solve a problem or perform a task.

If a method does not handle a possible checked exception, what must the method have?

a throws clause in its header

What is the following statement an example of? import java.util.*;

a wildcard import statement

A characteristic of ________ is that only an object's methods are able to directly access and make changes to an object's data.

data hiding

A declaration for an enumerated type begins with the ________ key word.

enum

Which key word indicates that a class inherits from another class?

extends

It is common practice in object-oriented programming to make all of a class's

fields private.

If a random access file contains a stream of characters, which of the following statements would move the file pointer to the starting byte of the fifth character in the file?

file.seek(8);

When a class implements an interface, an inheritance relationship known as ________ inheritance is established.

interface

Assume you are at the operating system command line and want to use the following command to compile a program: javac MyClass.java Before entering the command you must

make sure you are in the same directory or folder where the MyClass.java file is located.

When writing a string to a binary file or reading a string from a binary file, it is recommended that you use

methods that use UTF-8 encoding.

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

myView.setPreserveRatio(true);

By default, a reference variable that is an instance field is initialized to the value

null

When an event takes place, the control responsible for the event creates an event

object.

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.

The actions performed by the JVM that take place with each method call are sometimes referred to as

overhead.

A constructor is a method that

performs initialization or setup operations.

While ________ is centered on creating procedures, ________ is centered on creating objects.

procedural programming, object-oriented programming

A cross between human language and a programming language is called

pseudocode

In the ________, we must always reduce the problem to a smaller version of the original problem.

recursive case

In the hexadecimal color value #CCAA99, the CC refers to which color component?

red

You can use the ________ method to replace an item at a specific location in an ArrayList.

set

The term ________ is commonly used to refer to a string that is part of another string.

substring

Character wrapper class provides numerous methods for

testing and converting character data

In order to do a binary search on an array

the array must first be sorted.

The data contained in an object is known as

the attributes.

In a recursive program, the number of times a method calls itself is known as

the depth of recursion

When using the throw statement, if you don't pass a message to the exception object's constructor,

the exception will have a null message

In the following Java statement, what value is stored in the variable name? String name = "John Doe";

the memory address where "John Doe" is located

The ________ method returns a copy of the calling String object with all leading and trailing whitespace characters deleted.

trim

To get the name of a calling enum constant

use the toString method.

Which of the following statements will correctly convert the data type, if x is a float and y is a double?

x = (float)y;

A Java source file must be saved with the extension

.java

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

.root

Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8?

"000.0"

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

"is a"

If you want to use the System.out.printf method to print a string argument, use the ________ format specifier.

%s

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 is not a valid Java comment?

*/ Comment two /*

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(numbers);

0

How many times will the following for loop be executed? for (int count = 10; count <= 21; count++) System.out.println("Java is great!");

12

What will be the value of x after the following statements are executed? int x = 75; int y = 60; if(x > y) X = X - y;

15

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

18pts

What will be the value of x after the following statements are executed? int x = 10; switch (x) { case 10: x += 15; case 12: x -= 5; break; default: x *= 3;

20

What will be the value of x after the following code is executed? int X = 10, y = 20; While (Y < 100) { x += Y; Y += 20; }

210

You can use the enum key word to

Both of these

The ________ class is the wrapper class for the char data type.

Character

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

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

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

ClassB

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

ClassC

Which of the statements below give an alternative way to write the following: FileInputStream fstream = new FileInputStream("info.dat"); DataInputStream inputFile = new DataInputStream(fstream);

DataInputStream inputFile = new DataInputStream(new FileInputStream("info.dat"));

Which class specifies the amount of time an animation should last?

Duration

Unchecked exceptions are those that inherit from the

Error class or the RuntimeException class.

To write data to a binary file, you create objects from which of the following classes?

FileOutputStream and DataOutputStream

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

GridPane

Assume the following declaration exists: enum Tree ( OAK, MAPLE, PINE ) What will the following code display? System.out.println(Tree.OAK);

OAK

A(n) ________ is a software entity that contains data and procedures.

Object

Which of the following statements will create an object from the Random class?

Random myNumber = new Random();

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);

Assume the class BankAccount has been created and the following statement correctly creates an instance of the class. BankAccount account = new BankAccount(5000.00); What is true about the following statement? System.out.println(account);

The account object's toString method will be implicitly called.

What will be the value of ans after the following statements are executed? int x = 40; int y = 40; if (x = y) ans = x + 10;

The code contains an error and will not compile.

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.

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 minutes of the animation.

For the following code, which statement is not true? public class Circle { Private double radius; public double x; private double y; }

The y field is available to code written outside the Circle class.

Which class is used to move a node from one position on the screen to another?

TranslateTransition

When a character is stored in memory, it is actually the ________ that is stored.

Unicode number

What will be displayed after the following code is executed? String str = "RSTUVWXYZ"; System.out.println(str.charAt(5));

W

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

WriteObject

You cannot use the fully-qualified name of an enum constant for

a case expression.

Classes that inherit from the Error class are for exceptions that are thrown when

a critical error occurs, and the application program should not try to handle them.

A file that contains raw binary data is known as a

binary file

After the header, the body of the method appears inside a set of

braces, {}

The RandomAccessFile class treats a file as a stream of

bytes

Which of the following expressions determines whether the char variable, chrA, is not equal to the letter 'A'?

chrA != 'A'

In the ________ file format, when data in a spreadsheet is exported, each row is written to a line and commas are used to separate the values in the cells.

comma separated value

You can concatenate String objects by using the

concat method or the + operator.

In a UML diagram you show a realization relationship by connecting a class and an interface with a

dashed line with an open arrowhead at one end

Variables are classified according to their

data types

An item that separates other items is known as a

delimeter

When recursive methods directly call themselves, it is known as

direct recursion

An action that takes place while a program is running is a(n)

event

When a method is declared with the ________ modifier, it cannot be overridden in a subclass.

final

The ________ loop is ideal in situations where the exact number of iterations is known.

for

The JVM periodically performs the ________ process to remove unreferenced objects from memory.

garbage collection

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

have a throws clause in the method header.

Overloading is

having two or more methods with the same name but different signatures.

The ________ statement is used to create a decision structure which allows a program to have more than one path of execution.

if

Which is the key word used to import a class?

import

Which of the following import statements is required in order to use the ArrayList class?

import java.util.ArrayList;

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

import javafx.event.EventHandler;

Which statement tells the compiler where to find the JOptionPane class and makes it available to your program?

import javax.swing.JOptionPane;

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

import.javafx.scene.paint.Color;

A(n) ________ is a dialog box that prompts the user for input.

input dialog

When an object is created, the attributes associated with the object are called

instance fields.

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);

Which of the following is a valid declaration for a ragged array with five rows but no columns?

int[ ][ ] ragged = new int[5][ ];

A search algorithm

is used to locate a specific item in a collection of data.

Which of the following commands will run the compiled Java program named DoItNow?

java DoItNow

Which package contains the Insets class?

javafx.geometry

Validating the results of a program is important to

make sure the program solves the original problem.

A method

may have zero or more parameters

Class objects normally have ________ that perform useful operations on their data, but primitive variables do not.

methods

A ________ loop will always be executed at least once.

posttest

The two primary methods of programming in use today are

procedural and object-oriented.

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

setInput

The ________ method is used to display a message dialog.

showMessageDialog

Character literals are enclosed in ________ and string literals are enclosed in ________.

single quotes, double quotes

Like a loop, a recursive method must have which of the following?

some way to control the number of time it repeats

Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2?

str1.equalsIgnoreCase(str2)

In general, there are two types of files which are

text and binary.

Which of the following can you use to compare two enum data values?

the equals and compareTo methods

An object typically hides its data but allows outside code access to

the methods that operate on the data.

If a BorderPane region does not contain anything,

the region will not appear in the GUI.

What is syntax?

the rules that must be followed when writing a program

In an if-else statement, if the boolean expression is false

the statement or block following the else is executed.

To indicate the data type of a variable in a UML diagram you specify

the variable name followed by a colon and the data type.

The only limitation that static methods have is

they cannot refer to nonstatic members of the class.

Which of the following methods returns a string representing all of the items stored in an ArrayList object?

toString

A flag may have the values

true or false

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.

The "has a" relationship is sometimes called a(n) ________ because one object is part of a greater whole.

whole-part relationship

A partially filled array is normally used

with an accompanying integer value that holds the number of items stored in the array.

Which of the following expressions will determine whether x is less than or equal to y?

x <= y

Which of the following statements is(are) true about this code? final int ARRAY_SIZE = 10; long[] array1 = new long[ARRAY_SIZE];

All of these are true.

The foundation of a GUI application is the

Application class

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 statements opens a file named MyFile.txt and allows you to append data to its existing contents?

FileWriter fwriter = new FileWriter("MyFile.txt", true); PrintWriter outFile = new PrintWriter(fwriter);

A class becomes abstract when you place the ________ key word in the class definition.

abstract

A(n) ________ method is a method that appears in a superclass but expects to be overridden in a subclass.

abstract

Which of the following ArrayList class methods is used to insert an item at a specific location in an ArrayList?

add

When an "is a" relationship exists between objects, the specialized object has

all of the characteristics of the general object plus additional characteristics.

What is the following statement an example of? import java.util.Scanner;

an explicit import statement

Because Java byte code is the same on all computers, compiled Java programs

are highly portable.

What will be the value of x after the following statements are executed? int x = 10; for (int y = 5; y < 20; Y += 5) x += Y

40

Which of the following statements creates an empty TextArea?

TextArea textArea = new TextArea();

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

KEY_PRESSED

Given the following two-dimensional array declaration, which statement is true? int[][] numbers = new int[6][9];

The numbers array has 6 rows and 9 columns.

A set of programming language statements that perform a specific task is a(n)

procedure.

A ________ member's access is somewhere between public and private.

protected

One type of design tool used by programmers when creating a model of a program is

pseudocode

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

public class Salaried extends PayType

Which of the following is a correct method header for receiving a two-dimensional array as an argument?

public static void passMyArray(int[][] myArray)

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");

To change the alignment of an HBox you call the

setAlignment method.


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

Intermediate Accounting 2, Final

View Set

IB Biology 1 Unit 1- Properties of Water

View Set

Forensic psych Exam #2 Study Guide

View Set

Module 1 Section 2 the Institutes "Marketing"

View Set