Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

When programming, or solving any sort of problem for that matter, abstraction plays a key role in the decision-making process. It allows you to remove irrelevant details in order to understand the bigger picture.

For example, if you were constructing a program to inventory cars for sale at a used car lot, it would not make much sense to design a unique class for each separate car, especially if there are many vehicles in the lot. Instead, you would create a single "Car" class and personalize it for each vehicle.

Abstraction plays a key role in object-oriented programming. As the designer, you decide which characteristics are (and which are not) important as you define classes. In the context of the used car lot example, you could consider separate subclasses of the Car class for each make of car. Ordering classes hierarchically can save you time and effort.

For instance, a Corolla and a Camry are individual models of cars, but they both inherit certain characteristics from their shared make, Toyota.

However, hierarchies present their own challenges. Just because you can construct hierarchies, it does not necessarily mean that it is useful to do so. Consider the Unified Modeling Language (UML) class diagram below, which contains a set of subclasses for the superclass Car. In this chart, the "Car" class has characteristics for the color and registration number for the car. Stemming from the "Car" class are 3 subclasses, Ford, Volvo, and Toyota, which are for different car manufacturers.

In this case, creating separate subclasses of Car is more trouble that it is worth, because the inventory program probably does not have to treat different models of cars in different ways.

Therefore, it is probably more appropriate simply to designate the make of the car in a field of the class, as illustrated in the UML class diagram below. For this chart the "Car" class still has the color and registration number as characteristics.

However, the subclasses have been removed, and instead there is another characteristic of the "Car" class called "type" that accounts for the make of the car.

The larger question at play is this: "What characteristic of an object is significant enough to warrant a subclass rather than simply data in a field?" Think about an application in your field of expertise and the classes that you would define for that application.

Post a response that describes the application you choose and the class within that application.

Identify one or two key distinctions within that class that would prompt you to create subclasses instead of fields within the main class.

Explain your reasoning, giving specific examples of objects in each of the classes and subclasses you discuss, and draw a UML class diagram to support your claim.

Java, Programming

  • Category:- Java
  • Reference No.:- M92068779
  • Price:- $45

Guranteed 36 Hours Delivery, In Price:- $45

Have any Question?


Related Questions in Java

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As