Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is a class and what is a method of a class? Describe the relationship between a class and its methods. [10 pts) Write a

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
What is a class and what is a method of a class? Describe the relationship between a class and its methods. [10 pts) Write a program that is built out of the following classes: (50 pts) 1 Class Address that is defined by cityName, streetName, streetNumber, BuildingNumber, floorNumber, and apartmentNumber. Add all the necessary getter and setter methods. Also, add the toString method with the return type void. For constructors, you should have the default constructor and at least one parameterized constructor. Data should have a decent privacy level that protects it from being accessed from outside the class. 2 Class Company that is defined by the following attributes with the specified types: int numberEmployees, Address address, and int annualRevenue Add all getter and setter methods that you find necessary. Also, add the toString method with the return type void For constructors you should have the default constructor and at least one parameterized constructor. Data should have a decent privacy level that protects it from being accessed from outside the class. 3 Class Hospital which should be derived from the class Company. It should have the additional int type attributes number Doctors and numberPatients. Note that you should override the toString method For constructors, you should have the default constructor and at least one parameterized constructor 4 In the main class, define one object of type Hospital Print the data of the Hospital object Which of the following is a valid default constructor of the class Address? O a. public void Address O b. public Address(Moon moon) O c. public Address() Od public void Address(Moon moon) A static variable belongs to a O a object a. O b. attribute O c. method C. od class Which of the following functions takes all its input(s) by reference? O a. public void modify(int x) O b. public int read (Scanner x) O c. public void modify(double x, String y) Od public void modify(char x) Which of the following is passed by reference to a method? O a int Ob float Occhar O d. array Which of the following functions takes its input(s) by reference? O a. public void modify(boolean x) O b. public void read (double[] x) O c. public void modify(int x) Od public int modify(int y) Which of the following is not a primitive data type? O a. array O b. int O c. boolean Od double Which of the following is not true for a constructor method? O a Can have zero or more input arguments ob. Is invoked using the keyword new e. Has the void return type Od Has the same name as the class Which of the following functions takes its input(s) by value? O a. public double modify(int x) O b. public int | modify(int (1 x) O c. public void modify(int ( x) od public int modify(int (Jx, int (y)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Marketing Management

Authors: Mark Johnston, Greg Marshall

3rd edition

1259637158, 978-1259637155

Students also viewed these Accounting questions

Question

1. Let a, b R, a Answered: 1 week ago

Answered: 1 week ago