Essay: Introduction to Programming II

Essay: Introduction to Programming II
April 12, 2011 Comments Off on Essay: Introduction to Programming II Academic Papers on Information Technology,Sample Academic Papers admin

Sample Essay

Task 1

1. What techniques did you use for information hiding and encapsulation? Are there any improvements you would make? If so, what would they be?

Information Hiding and Encapsulation was achieved, by declaring a class in which data and method were combined in one shell. Then, all variable were declared as private, so that they can only be accessed by using public functions of the class and hide the implementation details of the Invoice class. A further improvement can be made by making it accessible to the classes which will be derived from it to further enhance the Invoice process. This can be done by declaring all private members as protected. (Gibson, 200)

2. Which members were instance members? Did you have any class members?

Instance variables are those, which are maintained as separate copies by each instance of the class. Here, companyName, amountDue, chargeDate and invoiceNumber were instance members. Class member or static members are maintained as a single copy for all instances of the class. Here, the class member was numberOfInvoices. (Sun Microsystems, 2008)

3. What would the result be if you made numberOfInvoices a final variable?

A final variable is a constant variable which means once a value is assigned to it, it can be changed. If numberOfInvoices was declared as final, the compiler would give error as we are trying to modify its value in the constructor. If the program was modified to be run, then the numberOfinvoices won’t change its value with each instance of the class.

D. Complete the attached reflection form and submit it for evaluation.

No workable form was found in the attachment.

Task 2

1. Explain how you used the Interface.

To implement the interface, the implements keyword is used after the declaration of class followed by the interface name. Here we have used the same technique by using implements keyword after the class declaration followed by Runnable which is the name of the interface.

2. Explain how overriding through an Interface was used.

An Interface can be defined as a group of methods with an empty body. These functions are defined in any class which implements the interface they are part of. Overriding was done by writing method definition of the function run() provided by the Runnable interface which superseded any previous definition of function run().

3. Lead a discussion with your attendees on the differences between Overriding and overloading.

Overloading is a feature which allows for multiple definitions of methods with the same name. The difference between them is of signature, that is, parameters. Overriding allow for providing a new definition of a method with same parameters, in the derived class.  Both overloading and overriding are different aspects of polymorphism. Overloading can be called static or early binding polymorphism because it gives an impression that a method would accept multiple types of parameters. Overriding can be all dynamic polymorphism because any implementation differences are only seen at runtime. (Gibson, 200)

Please go to the order form to order essays, research papers, term papers, thesis, dissertation, case study, assignments on this essay topic.

Related Essays, Research Papers, Term Papers, Thesis, Dissertation, Case Study, Assignments entries.

...

BUY CUSTOM ESSAY

...

Tags
About The Academic Paper