DIT 0503 Advanced Object Oriented Programming CAT2
DIT 0503 Advanced Object Oriented Programming CAT2
QUESTION 1
i. Encapsulation
ii. Constructor
iii.Polymorphism
ii) Give an example showing the syntax of try block and catch block with an example
iii) Explain the following keywords.
i. extends
ii. abstract
iii. iii. super
Question 2
a) Write a Java class called Invoice that a hardware store might use to represent an invoice for an item
sold at the store. An Invoice should include four pieces of information as instance variables—a part
number (type String), a part description (type String), a quantity of the item being purchased (type int)
and a price per item (type double). Your class should have a constructor that initializes the four instance
variables. Provide a set and a get method for each instance variable. In addition, provide a method named
getInvoiceAmount that calculates the invoice amount (i.e.,multiplies the quantity by the price per item),
then returns the amount as
adoublevalue.
ii. setForeground( )
Question 3
Write a Java application, with a class named Multiplication, which uses the command line to obtain
integers from the user and a message dialog box to display the product of the integers
Question Four
a) Write a simple java program that can create and display a frame named MyFrame on the
screen.