Question: 1. When does a logic error get detected? a. At compile time b. At run time, and causes the program to stop and display the

1. When does a logic error get detected?

a.

At compile time

b.

At run time, and causes the program to stop and display the error

c.

When the program is run multiple times

d.

At run time, but the program does not stop or display that an error occurred

2. To create a window in an application using JavaFX, you must extend which class?

a.

none of these choices

b.

Applet

c.

EventHandler

d.

Application

e.

JFrame

3. Which ONE or MORE of the following, if any, ARE characteristics of Object-Oriented Programming? (you may select zero, one, or more than one choice)

a.

A class can be thought of as a category from which multiple "instances" or objects can be created.

b.

Object-Oriented Programming often results in "spaghetti code" that is hard to follow

c.

Flow of control is structured so that one function after another can manipulate data, which is available globally to all functions.

d.

Classes can inherit characteristics from other classes.

e.

Data and behaviors are grouped together in objects

4. Which of the following serves as a template for objects to be created?

a.

class

b.

array

c.

field

d.

method

5. What will be displayed as a result of executing the following code? int counter = 4; String string = "Think before you code"; System.out.println(string+". Character number "+(counter+1)+" is "+string.charAt(counter)); string = string.toLowerCase(); System.out.println(string+". Character number "+(counter)+" is "+string.charAt(--counter)); System.out.println("string is "+string.length()+" characters long.");

a.

Think before you code. Character number 4 is k THINK BEFORE YOU CODE. Character number 3 is N string is 21 characters long.

b.

Think before you code. Character number 5 is k think before you code. Character number 4 is n string is 21 characters long.

c.

Think before you code. Character number 4 is n think before you code. Character number 3 is n string is 21 characters long.

d.

This code will not compile.

6. Which of the following does NOT indicate a comment in Java?

a.

Starts with two semi-colons, that is, ;;

b.

/**

...

*/

c.

Starts with two slashes, that is, //

d.

/*

...

*/

7. What will be printed out as a result of the following code? int x = 5, y = 7; System.out.println(++x); x += y++; System.out.println(x + "," + y);

a.

6 6,8

b.

6 13,8

c.

5 13,8

d.

5 12,7

8. Encapsulation is a key principle of structured programming. It states that a class should contain private data and public methods to manipulate that data

True

False

9. One problem with Java is that a Java program has to be recompiled for each type of computer it will run on.

True

False

10. Assume that myVar is correctly declared as an array, and then initialized as myVar = {17,30,2,51};

Will the following will correctly print out the values of the myVar array? for (int i=0; i<=4; i++) { System.out.println(myVar[i]); }

True

False

11. GUI programs, whether using the Swing Java API or the JavaFX API, use events. What does an event do?

a.

none of the above

b.

An event is thrown when an error occurs in the program.

c.

An event is an object that signals that a GUI component has been used (for example, a button has been pushed, a text field has text entered, etc.)

d.

An event is an object that is effectively final, i.e., it is set once and cannot be reset.

e. An event launches the initial GUI, then is deleted.'

12. What does the Scanner object do when instantiated as follows?

Scanner myScanner = new Scanner (System.in);

a.

It reads keystrokes from the keyboard.

b.

Scanner prints output to the console.

c.

It scans a String object character by character to remove any non-printable characters.

d.

The programmer must define the class Scanner and specify what it does.

13. When using JavaFX, the program must call the method "launch", which is predefined and calls the method "start", which is implemented by the programmer.

True

False

14. Given the following declaration: double deposit; then the following statement is valid (T/F)

15. Which of the following code snippets will correctly swap the values contained in variables num1 and num2 (assume all variables are declared as int and previously initialized)

a.

myVar1 = temp;

myVar2 = myVar1;

temp = myVar2;

b.

myVar1 = temp;

myVar2 = myVar1;

myVar1 = myVar2;

c.

temp = myVar1;

myVar1 = myVar2;

myVar2 = temp;

d.

myVar1 = myVar 2;

myVar2 = myVar 1;

deposit = $2,100.00;

True

False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!