Java Programming

Download Report

Transcript Java Programming

Java Programming
Daily review / 1 PT. each
September 28/29: Lesson 1 - a
• 1. Create the “skeleton” of a program
Public class Tester
{
Public static void main(string voids[])
{
}
{
• 2. Write a line of code that will cause the word Hello to be printed.
System.out.println(“Hello”);
• 3. Define the following words:
• A. Rem:
• B. skeleton:
• C. code:
comment or remark
beginning format that must be typed to begin coding
piece of text in Java
September 30/October 1: Lesson 1 - b
• 1. Consider the following code:
System.out.print(“Fire”);
System.out.println(“Ants”);
• What does the above print?
Fire Ants
• 2. What is the syntax for indicating that line of text is not Java code; rather it is a rem?
// How do you create a rem?
• 3. How do you create a block rem?
/* How do you create a block rem */
• 4. Define the following words:
A.
B.
C.
Compile: Assembling or transforming source code written in a programming language.
B. Container: Brackets that enclose coding
C. Java: one of the many programming languages
Oct. 2/5: Lesson 1 - c
1.
Supply code in the place of the below, that will produce the following printout:
From: your name
Address: Baldwin Middle Senior High School
To: Margaret Winter
Message: I love java programming!
public class Tester
{
public static void main(String args[])
{
System.out.println("From: Student Name");
System.out.println("Address: Baldwin Middle Senior High School");
System.out.println("");
System.out.println(“To: Margaret Winter");
System.out.println("");
System.out.println("Message: I love java programming");
}
}
October 8/9: Lesson 3
1. What is output by the following code?
String s = “Mona Lisa”;
System.out.println(s.length( ));
2. What is the output of System.out.println( p.toUpperCase( ) ); if p = “Groovy Dude”?
3. What is output by the following code?
String girl = “Heather Jones”;
System.out.println(girl.substring(8));
4. What is output by the following code?
String girl = “Heather Jones”;
System.out.println(girl.substring(8,11));
October 12/13: Lesson 3
1. What is the index of the ‘L’ in the String “Abraham Lincoln”
2. What is output by the following code?
String s = “Beaver Cleaver”;
System.out.println(s.toUpperCase( ));
3. Write code in which a String variable s contains “The number of rabbits is”. An integer variable
argh has a value of 129. Concatenate these variables into a String called report. Then print
report. The printout should yield:
The number of rabbits is 129.
Note that we want a period to print after the 9.
October 14/15: Lesson 3
1. Write code that will assign the value of “Computer Science is for nerds” to the String variable g.
Then have it print this String with nothing but “small” letters.
2. What will be the value of c?
String c;
String m = “The Gettysburg Address”;
c = m.substring(4);
3. What will be the value c?
String b = “Four score and seven years ago,”;
String c = b.substring(7, 12);
4. What is the value of count?
int count;
String s = “Surface tension”;
count = s.length(