1) Part 3 of the missing integer problem.
https://sites.google.com/site/ajaymittalinstructor/home/java/intialization-and-cleanup#TOC-Exercises
2) Both exercises at:
https://sites.google.com/site/ajaymittalinstructor/home/java/access-control#TOC-Exercises
June 12th 2019
//-------------------------------------------------------------------------------------------------------------------------
Exercise 1a
Create a public class called "vehicle" in a file called "vehicle.java" . Create another class in this file called "engine" . The "engine" class is not public. The "vehicle" class will have an object of the engine class. Initialize this object in the vehicle constructor using the "new" syntax .
Page 191 Ex2
Page 192 Ex 3 , 4 , 5
Page 193 Ex 8
Exercise 2a
Create a base class called house that has a method called :
int getPrice()
The class "house" has a data member variable called "price" that is of type "int" and "getPrice()" will return the variable "price" .
Create a derived class called "condo" that also has a method "getPrice()" and that also will return the variable price. Put the "@Override" annotation before this method.
In the main class do
house houseObj = new condo() ;
houseObj.getPrice() ;
make sure the above code calls the "condo" getPrice method . Change the signature of the "condo" , "getPrice()" method and note the compiler error.
Page 202 Ex 15
Page 202 Ex 18
Exercise 3a:
File: "blankfinal.java"
public class blankfinal
{
public final int i1 = 0; // Initialized final
public final int j1; // Blank final
public blankfinal()
{
System.out.println( "Constructor." ) ;
}
public void method1()
{
j1 = 1 ;
}
public static void main(String args[] )
{
blankfinal obj1 = new blankfinal() ;
obj1.method1() ;
System.out.println( obj1.j1 ) ;
}
}
The above file gives a compiler error. Fix the error.