OBJECTS FIRST WITH JAVA A
PRACTICAL INTRODUCTION
USING BLUEJ 6TH EDITION
BARNES SOLUTIONS MANUAL
,:
Exercise 2.2
Zero.
Exercise 2.3
If too much money is inserted the machine takes it all - no refund.
If there isn't enough money inserted, it still prints out the ticket.
Exercise 2.5
It looks almost completely the same. Only the price on the ticket is different.
Exercise 2.6
The outer part of the student class:
public class Student
{
}
The outer part of the LabClass class:
public class LabClass
{
}
Exercise 2.7
Yes, the order of public and class matters.
Exercise 2.8
It is possible to leave out the word public.
Exercise 2.9
It is not possible to leave out the word class.
Exercise 2.10
Fields:
price
balance
total
Constructors:
TicketMachine
, Methods:
getPrice
getBalance
insertMoney
printTicket
Exercise 2.11
It does not have any return type. The name of the constructor is the same as the
name of the class.
Exercise 2.12
int
Student
Server
Exercise 2.13
alive
tutor
game
Exercise 2.14
Student, Server, Person and Game
Exercise 2.15
The exact order matters.
Exercise 2.16
Yes, it always necessary to have a semicolon after a field declaration.
Exercise 2.17
private int status;
Exercise 2.18
It belongs to the class Student.
Exercise 2.19
It has two parameters. One is of type String and the other of type double.
Exercise 2.20
It would be reasonable to expect the types to be the same as the two parameters
(String and double).
PRACTICAL INTRODUCTION
USING BLUEJ 6TH EDITION
BARNES SOLUTIONS MANUAL
,:
Exercise 2.2
Zero.
Exercise 2.3
If too much money is inserted the machine takes it all - no refund.
If there isn't enough money inserted, it still prints out the ticket.
Exercise 2.5
It looks almost completely the same. Only the price on the ticket is different.
Exercise 2.6
The outer part of the student class:
public class Student
{
}
The outer part of the LabClass class:
public class LabClass
{
}
Exercise 2.7
Yes, the order of public and class matters.
Exercise 2.8
It is possible to leave out the word public.
Exercise 2.9
It is not possible to leave out the word class.
Exercise 2.10
Fields:
price
balance
total
Constructors:
TicketMachine
, Methods:
getPrice
getBalance
insertMoney
printTicket
Exercise 2.11
It does not have any return type. The name of the constructor is the same as the
name of the class.
Exercise 2.12
int
Student
Server
Exercise 2.13
alive
tutor
game
Exercise 2.14
Student, Server, Person and Game
Exercise 2.15
The exact order matters.
Exercise 2.16
Yes, it always necessary to have a semicolon after a field declaration.
Exercise 2.17
private int status;
Exercise 2.18
It belongs to the class Student.
Exercise 2.19
It has two parameters. One is of type String and the other of type double.
Exercise 2.20
It would be reasonable to expect the types to be the same as the two parameters
(String and double).