TeacherWeb

TV Production I/II & Java I/II/III



Top Divider


Java Chapter 2 Test 1


Your Name:


Your Email Address:



Instructions:
Please respond to the following. Make sure to enter your name and 
email address before you submit the test online. Only submit it one 
time!

1)
An outer wrapper contains {  }
      True              False

2)
{ } are also known as curly braces and/or curly brackets.
      True              False

3)
The first letter of a class must always start with an upper case 
letter.
      True              False

4)
The first letter of a class must always start with a lower case 
letter.
      True              False

5)
//The following is a better ticket machine.
The above sentence is an example of a single line comment.
      True              False

6)
//**The following is a better ticket machine,
The above sentence is an exmaple of a single line comment.
      True              False

7)
"Playa" is a java key word.
      True              False

8)
Java code usually contains fields, constructors, and methods.
      True              False

9)
Java code usually contains assignment statements and conditional 
statements.
      True              False

10)
Assignment statements have an equal sign  =  in them.
      True              False

11)
The following is a java key word:
      staticfp
      static fp
      statics fp
      staticsfp


12)
The following is the proper way to start a java class:
      public class TicketMachine {
      Public class TicketMachine }
      Public Class TicketMachine {
      public Class ticketMachine }


13)
The following is an assignment statement
      balance = 0
      balance = 0;
      balance = 0 {
      balance = 0,


14)
The following is the most closely related to a conditional 
statement:
      public void printTicket ( )
      public int getPrice ( )
      public void insertMoney (int amount) { if (amount > 0) }
      private int price;


15)
The following are fields:
      private int price;
      private int balance;
      private int total;
      all of the above


16)
The following is the proper way to write a constructor:
      Public TicketMachine ( int ticket cost) }
      public TicketMachine ( int ticketCost) {
      ticketMachine ( int ticketCost) {
      Void TicketMachine ( int Ticket Cost);


17)
Which of the following will return the price of a ticket?
      Public int getprice ( );
      public int return price;
      public int getPrice ( ) { return price; }


18)
Which of the following will return the balance?
      Public int getbalance ( );
      public int return balance;
      public int getBalance ( ) { return balance; }


19)
Which of the following will let you insert money?
      public int insertMoney ( int amount ) { bal = bal + amount;}
      Public int insrtmoney ( );
      public int insert money;


20)
Which of the following will allow you to print a ticket?
      Public print Ticket ( );
      Public void Print the Ticket:
      public void printTicket ( ) { System.out.println ( ); }


21)
Which of the following are acceptable ways of starting a class?
      public class TicketMachine
      class TicketMachine
      Neither of the above.
      Both of the above


22)
Which of the following is the proper way to write out the class 
called student.
      public class student
      public class Student
      class student
      You cannot use student as a class because it is a key word.


23)
The fields store data for:
      Each parameter to use.
      Each integer to use.
      Each class to use.
      Each object to use.


24)
The constructors allow:
      Each class to be set up properly when it is first created.
      Each class to store integers properly.
      Each object to be set up properly when it is first created
      Each object to use a print line method.


25)
The methods implement the behavior of:
      The objects.
      The class.
      The constructors.
      The fields.


26)
This is an extra credit question! (Worth 4 points)
Which of the following is the proper order inside the outer wrapper 
curly brackets that is preferred by the author of your text book.
      Fields, constructors, methods.
      Constructors, fields, methods.
      Methods, fields, constructors.
      Constructors, methods, fields.
      Fields, methods, constructors.
      None of the above.


27)
Name 25 Java Keywords (reserved words for the Java technology 
language). (1 point each)


28)
Extra Credit!
Name 10 more Java Keywords (reserved words for the Java technology 
language.) (1/2 point each,rounded up)


29)
Write a correct java code for the following: (50 points total)

1. An outer wrapper with a class named TicketMachine. (10 points)

2. Fields containing price, balance,and total. (10 points)

3. A constructor that is public TicketMachine (int ticketCost). (10
   points)

4. It must contain the three assignment statements of:
    price = ticketCost; balance = 0; and total = 0. (10 points)
    
5. The code must be able to getPrice and return the price,      
   getBalance and return the balance, and simulate the 
   printing of a ticket. (10 points)




     

Bottom Divider

My TeacherWeb
Last Modified: Friday September 12 2008
© 2003-2008 TeacherWeb, Inc.