Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java - Inheritance and Object Oriented Programming

dickersonka
dickersonka 


Instructions: • For this assignment, please address the following questions. • Please respond substantively to each question and avoid one-line sentences • For each answer, where appropriate, cite your answer per APA documentation format. In other words, tell me the source of your answer. You can cite pages in your textbook that contain the answer; or you can also use trusted resources found via Internet as your resources. IMPORTANT: Use your Word Processor (i.e. Microsoft Word) to answers the questions below. For the ones that involve coding, you could also just type up your code in the same Word document; or, you many choose to use JGRASP and then attach the .JAVA files. Make sure you have some Java comments that indicate what question you're answering. Questions: 1. (1) There are many different concepts associated with OOP (Object-oriented programming) like: • Class • Object • Inheritance • Polymorphism • Abstraction • Encapsulation • Interface • Method Overloading • Method Overriding • …and others QUESTION: Pick FIVE of the above listed OOP concepts and describe each in details (10 points) Class – A class is a conceptual model that contains specific properties and functionality that is pertinent to this specific entity. It groups all these properties and methods into a model, known as a class. Object – An object is an instance of a class. All classes in their most basic form inherit from Object. Objects are the basis of object oriented programming. Inheritance – Inheritance allows code reuse and functionality or properties to be defined as a base class. Two child classes that have the same parent class, can both inherit structure and functionality and are considered to be instances of the parent class. Polymorphism – Polymorphism is using parent and child classes to allow differing functionality with with same calling conventions. If a Dog and Cat class inherited from Animal, then both could implement a speak method, but the implementation would be able to be different. Abstract – An abstract class is also referred to as a base class that cannot be instantiated. This base class must be inherited and instantiated as the client class. Typically abstract classes will contains abstract methods that will be an outline of functionality that must be implemented in the child classes. 2. (2) In Java (and OOP), Inheritance involves the concept of super class (parent class) and sub class (derived class). What is a super class in Java? What is a sub or derived class in Java? (2 points) (3) 3. Code a simple class in JAVA classed “Student.” Your class must contain the followings (4 points): • Variables (name, age, addressStreet, city, state, zip, country)(Jodi Hodges, 26, 2208 Clinton Rd, Fayetteville, NC, 28314, USA) • Setter and Getter methods Example: public void setName(String name) { this.name = name; } public String getName() { return name; } 4. (4) Code a short JAVA program that demonstrates Inheritance (4 points). HINT: • To demonstrate true OOP inheritance, your code must include a super (parent) class and a sub class (derived class) • As an example, class Student could be a super class while class GraduateStudent is a sub class that inherits from Student class. • In your subclass (i.e. GraduateStudent), you must include the JAVA inheritance keyword that shows that a class inherits from another. Attachments Tags Clarifications

Answers

Java - Inheritance and Object Oriented Programming Solution

dickersonka
dickersonka 



Attached is the written and coded answers to the assignment Java - Inheritance and Object Oriented Programming Attachments
1and2.doc (23 K) Download
Student.java (1 K) Download Preview
city) { this.city = city; } public String getState() { return state; } public void setState(String state) { this.state = state; } public int getZip() { return zip; } public void setZip(int zip) { this.zip = zip;

GraduateStudent.java (1 K) Download Preview
//Create new student of graduate student Student gradStudent = new GraduateStudent(); gradStudent.setName("Jodi Hodges"); gradStudent.setAge(26); gradStudent.setAddressStreet("2208 Clinton Rd"); gradStudent.setCity("Fayetteville"); gradStudent.setState("NC"); gradStudent.setZip(28314); gradStudent.setCountry("USA");

Screenshots
Purchase Answer