Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA QUESTION: Consider the following code Calling Class: Classes Envelope e = new Envelope(0); e.etype++; System.out.println(e.getWeight()); GiftBox g = new GiftBox(); System.out.println(p.getWeight()); public class Package

JAVA QUESTION:

Consider the following code

Calling Class:

Classes

Envelope e = new Envelope(0);

e.etype++;

System.out.println(e.getWeight());

GiftBox g = new GiftBox();

System.out.println(p.getWeight());

public class Package {

public int getWeight(int a , int b) {

return a*b;

}

}

public class Envelope extends Package {

public int etype;

public Envelope(int a) {

etype =a;

}

public int getWeight() {

if (etype == 1) {return 6;}

return 7; }

}

public class Box extends Package{

int w,h;

public Box (int a , int b) {

w=a; h=b;

}

public Box () {

w = 5; h = 2;

}

public int getWeight() {

return w*h; }

}

public class GiftBox extends Box {

public GiftBox() {

super();

}

public int getWeight() {

return super.getWeight() - 2 ;

}

}

public class Customer {

protected ArrayList boxes;

public Customer(Box inbox) {

boxes = new ArrayList();

boxes.add(inbox); }

}

- What would be the output of the Calling class execution?

- Draw the UML diagram for these classes showing relationships and association. Use class names only, do not list properites or methods.

- Name all parent-child combinations.

- Should the annotation @Override be applied to the getWeight method overridden in the Envelope class?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Describe the important provisions of a commercial umbrella policy.

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago