Mr. Truncale - Robert E. Lee High School
Home
Digital Media
HTML
Video Game Design
Comp. Programming I
Comp. Programming II
AP Computer Science
3D Printing
Teacher Resources
Contact Me
Java Test 1-3
*
Indicates required field
Name
*
First
Last
ID Number
*
1. What is wrong with the following “skeleton” of a Java program?
public class MyClass
{
public static void main(String args[])
{
}
}
Choose One
*
public and class on the first line should be interchanged
MyClass name is wrong
There should not be a [ ] after args
Nothing is wrong
None of these
2. Which line of code will cause Hello to be printed?
*
System.out.println(“Hello”);
System.out.println(Hello);
System.out.println(“Hello”)
All of these
None of these
3. What is actually printed with the following code?
System.out.print(“Fire”);
System.out.println(“ Ants”);
Choose One
*
FireAnts
Fire Ants
Fire (on one line) Ants (on the next line)
Pants on fire
None of these
4. What is the syntax for indicating that a line of text is not Java code; rather, it is a remark?
*
rem
\\
//
comment
None of these
5. What are the three variable types we have studied up to this point?
*
String, float, spinner
integer, dblPrec, ace
int, double, word
String, int, double
None of these
6. Suppose you have the number 189.24. Which variable type would you use to store this number?
*
String
int
double
tupperWare
None of these
7. Which line of code declares k to be an integer?
*
k int;
int k;
integer k;
k integer;
None of these
8. Which of the following is an illegal name for a variable?
*
Num
flag-stuff
12flag
flag_stuff,
More than one of these
9. Which of the following is the most desirable way to name a variable?
*
redcolor
red_color
redColor
RedColor
All are equally desirable
Both B and C
10. What is output by the following code?
String s = “Mona Lisa”;
System.out.println(s.length( ));
Choose One
*
7
illegal code
8
9
none of these
11. What is output by the following code?
String girl = “Heather Jones”;
System.out.println(girl.substring(8));
Choose One
*
Heather (one space after the 'r')
er Jones
Jones
8Jones
None of these
12. What is output by the following code?
String girl = “Heather Jones”;
System.out.println(girl.substring(8,11));
Choose One
*
Jon
one
ones
ather Jones
None of these
13. What is the index of the ‘L’ in the String “Abraham Lincoln”?
*
9
8
7
0
None of these
14. What is output by the following code?
String s = “Beaver Cleaver”;
System.out.println(s.toUpperCase( ));
Choose One
*
beaver cleaver
BEAVER CLEAVER
b
bEAVER cLEAVER
none of these
15. CODE PART
Given:
String name = "Bill Gates";
Use the string name and the substring method as shown in lesson 3 to display the output below:
Your first name is Bill.
Your last name is Gates.
Put code here
*
Submit