• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/41

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

41 Cards in this Set

  • Front
  • Back
1.
Which of the following is true?
A) Java programs can run on different platforms, like Windows and Unix, without being recompiled.
2.
What kind of Java program runs within a Java-enabled browser?
B) an applet
3.
Bytecodes are
D) input to the Java interpreter
4.
To achieve platform independence, the Java virtual machine
B) interprets the bytecodes
5.
Which of the following isn’t a benefit of a typical IDE for Java?
D) Your code compiles and runs faster.
6.
Which of the following is not true of using a IDE to develop Java programs?
D) It’s harder to detect syntax errors.
7.
The NetBeans IDE stores all of the files for an application in a
C) project
8.
In NetBeans, the class that contains the main method for an application is known as the
B) main class
9.
In NetBeans, what tool do you use to enter and edit source code?
D) code editor
10.
To create a Java source file, you use a
A) text editor
11.
The extension for a Java source file is
D) java
12.
As you develop a Java program, you can use NetBeans to
A) enter and edit the source code
B) compile the source code
C) run the application
D) all of the above
13.
Since NetBeans does this automatically, you typically don’t need to
A) compile/build a project
Correct Answer(s): A
14.
What window does NetBeans use to get input from a console application?
B) the Output window
15.
When you have two or more projects open in NetBeans, you can make it easier to run one project by setting it as the
C) main project
16.
What dialog box do you use to set the Java version for a project?
D) the Project Properties dialog box
17.
What NetBeans feature can help you enter a method by displaying a list of methods that are available from an object or class?
A) the code completion feature
18.
A syntax error occurs when
C) a statement won't compile
19.
When NetBeans detects a statement that has a syntax error, what does it do?
B) it places a red wavy line under the statement
20.
You typically use comments in a Java application to
A) describe statements that are difficult to understand
21.
Which of the following is a valid variable name?
A) salesTax
22.
Which of the following is a valid class name?
C) CustomerMaintApp
23.
According to standard naming conventions, which of the following is a typical class name?
C) Product
24.
Based on the naming recommendations in the book, which of the following is a good identifier for a variable that will be used to hold an employee’s phone number?
C) employeePhoneNumber
25.
Which of the following can you not assign to a numeric variable?
B) null
26.
Which of the following is a valid statement for declaring and initializing a double variable named length to a starting value of 120?
C) double length = 120.0;
27.
To refer to a Java class from an application without qualifying
C) you need to import the class.
28.
What does the following statement do in a Java application?
import java.util.Scanner;
A) It makes the Scanner class available to the application without qualification.
29.
Which of the following can you not use the Java API documentation to research?
C) debuggers
30.
You can use a Scanner object to:
A) get data from the console
31.
You can use a System.out object to:
C) display a blank line on a console
32.
Assume userName equals “Tom” and userAge equals 22. What is printed on the console when the following statement is executed?
System.out.println(userAge + " \nis " + userName + "'s age.");
B) 22
is Tom's age.
Correct Answer(s): B
33.
You can use relational operators to
B) compare numeric variables
34.
After the if statement that follows is executed, what will the value of discountAmount be?
double discountAmount = 0.0;
double orderTotal = 200.0;
if (orderTotal > 200)
discountAmount = orderTotal * .3;
else if (orderTotal > 100)
discountAmount = orderTotal * .2;
else
discountAmount = orderTotal * .1;
C) 40.0
35.
How many times will the while loop that follows be executed if months has a value of 5?
int i = 1;
while (i < months)
{
futureValue = futureValue * (1 + monthlyInterestRate);
i = i+1;
}
B) 4
36.
Block scope means that a variable
A) can’t be used outside of the set of braces that it’s declared in
public class InvoiceApp
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String choice = "y";
while (choice.equals("y"))
{
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();
double salesTax = subtotal * .0875;
double invoiceTotal = subtotal + salesTax;
String message = "Subtotal = " + subtotal + "\n"
+ " Sales tax = " + salesTax + "\n"
+ "Invoice total = " + invoiceTotal + "\n\n"
System.out.println(message);
System.out.print("Continue? Enter y or n: ");
choice = sc.next();
}
}
}
B) InvoiceApp.java
public class InvoiceApp
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String choice = "y";
while (choice.equals("y"))
{
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();
double salesTax = subtotal * .0875;
double invoiceTotal = subtotal + salesTax;
String message = "Subtotal = " + subtotal + "\n"
+ " Sales tax = " + salesTax + "\n"
+ "Invoice total = " + invoiceTotal + "\n\n"
System.out.println(message);
System.out.print("Continue? Enter y or n: ");
choice = sc.next();
}
}
}
(Refer to code example 2-1.) If the user enters 100 the first time the while loop is executed, what will the program display at the console?
D) Subtotal = 100.0
Sales tax = 8.75
Invoice total = 108.75
Points Earned: 1.0/1.0
Correct Answer(s): D
public class InvoiceApp
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String choice = "y";
while (choice.equals("y"))
{
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();
double salesTax = subtotal * .0875;
double invoiceTotal = subtotal + salesTax;
String message = "Subtotal = " + subtotal + "\n"
+ " Sales tax = " + salesTax + "\n"
+ "Invoice total = " + invoiceTotal + "\n\n"
System.out.println(message);
System.out.print("Continue? Enter y or n: ");
choice = sc.next();
}
}
}

(Refer to code example 2-1.) If the user enters “Y” when asked if he/she wants to continue, the application will
C) end
Points Earned: 0.0/1.0
Correct Answer(s): C
40.
A runtime error occurs when
B) bytecodes can’t be interpreted properly
41.
A compile-time error occurs when
C) there’s a syntax error in a Java statement
Correct Answer(s): C