Practice

Abstract Classes: University

Create an abstract class called University. It should have a constructor that takes two strings, one for name and one for location and assigns them. Then, create a child class that extend University, called College, with one more constructor argument than University (i.e. 3)

Template code

Solution code

Abstract Classes: Restaurants

Create an abstract class Restaurant, Then create four classes of your favorite restaurants and it should print the food it makes.

Template Code

Solution Code

Abstract Methods: University

Using the abstract class University that we made last time, make an abstract method for University. Then, in College class, override the abstract method to make it print out the class’ attributes.

Template Code

Solution Code

Interfaces: Triangle

Create class Square and class Triangle that implement the interface Shape. In the sides method, explain how many sides each shape has. Ex. “I have ___ sides!”

Template Code

Solution Code

Interface: Comparable