Q.1 a) Differentiate between abstract class and an interface. Briefly explain when we use abstract class...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Q.1 a) Differentiate between abstract class and an interface. Briefly explain when we use abstract class and interface in any project? (5) b) Write the code of the following scenario. (9) Create an abstract class Worker that has instance variables name and age. Create a parameterized constructor that initialized these instance variables. Create getter and setter of each instance variable. Write a method Output which should use the getter methods of each variable to show the value of each instance variable. In worker class add an abstract method Calculate Payment having double return type. Create Hourly Worker class that inherits Worker class having instance variables price and hours of data type int. Create getters for both instance variables. Create a parameterized constructor in such a way that it should initialized data members of this class as well as parent class. Create setter for price in such a way that it should not accept negative values. Create setter for hours in such a way that it should accept values from 0 to 30 only. Complete CalculatePayment method by price multiply by hours. Override Output method in this class also in such way that it should call first parent class Output and then use the getter method of each instance variable to show the value of each instance variable. Create a class name Driver having main method. Create an object of child class and test all possible functions. Ans. Write your answer here Q.1 a) Differentiate between abstract class and an interface. Briefly explain when we use abstract class and interface in any project? (5) b) Write the code of the following scenario. (9) Create an abstract class Worker that has instance variables name and age. Create a parameterized constructor that initialized these instance variables. Create getter and setter of each instance variable. Write a method Output which should use the getter methods of each variable to show the value of each instance variable. In worker class add an abstract method Calculate Payment having double return type. Create Hourly Worker class that inherits Worker class having instance variables price and hours of data type int. Create getters for both instance variables. Create a parameterized constructor in such a way that it should initialized data members of this class as well as parent class. Create setter for price in such a way that it should not accept negative values. Create setter for hours in such a way that it should accept values from 0 to 30 only. Complete CalculatePayment method by price multiply by hours. Override Output method in this class also in such way that it should call first parent class Output and then use the getter method of each instance variable to show the value of each instance variable. Create a class name Driver having main method. Create an object of child class and test all possible functions. Ans. Write your answer here
Expert Answer:
Answer rating: 100% (QA)
Differentiate between abstract class and interface A Abstract class Abstract class has a concrete bo... View the full answer
Related Book For
Project Management A Managerial Approach
ISBN: 978-0470226216
7th Edition
Authors: Jack R. Meredith, Samuel J. Mantel,
Posted Date:
Students also viewed these programming questions
-
Create an interface MessageEncoder that has a single abstract method encode(plainText), where plainText is the message to be encoded. The method will return the encoded message. Create a class...
-
For each graph, name the parent function and write an equation of the graph. a. b. c. d. e. f. g. h. 909 Dtt
-
Write a Super class interface employee has name and id number. Write manager and labour derived from employee class. Manager class has member data qfunction and qualification and manager allowance...
-
1. The operations manager for a well-drilling company must recommend whether to build a new facility, expand his existing one, or do nothing. He estimates that long-run profits (in $000) will vary...
-
Explain the effect of the Sarbanes-Oxley Act on the need for organizations to improve data quality.
-
(a) Plot the above data on a graph. Do you observe any trend, cycles, or random variations? (b) Starting in year 4 and going to year 12, forecast demand using a 3-year moving average. Plot your...
-
The plaintiff, Thelma Agnes Smith, lived with the defendant out of wedlock for several years. When the relationship ended, she sued the defendant, seeking to enforce two written agreements with him...
-
Recording Capital Projects Fund Transactions. In Erikus County, the Parks and Recreation Department constructed a library in one of the countys high growth areas. The construction was funded by a...
-
AVC Company sold 250 units on account for $ 1 comma 100 each. The standard cost of each unit is $ 800. Under a justminusinminustime costing system, the journal entries that are recorded for the 250...
-
I need help on this read from bottom to top. Image transcription text 7"} The second ?nancial statement to prepare is the statement of retained earnings. To determine the ending balance of...
-
Sketch the graph of the following function and use it to determine the following limits. If a limit does not exist, type DNE. for x -1 for - 1 1 1. lim f(x) = 2. lim f(x) = 3. lim f(x) = X--1 4....
-
Describe three or four challenges you see in achieving an effective work environment, and identify resources needed to achieve balance in a changing workplace.
-
Calculate the velocity of a car (in m/s) that starts from rest and accelerates at 3 m/s for 6 seconds. Your Answer:
-
Why not give the user and kernel threading capabilities that the Sun Solaris operating system offers a try? What are some of the advantages and disadvantages of the threading strategy that the...
-
Need a single Linux pipeline command to display the number of files in your current directory that match the pattern "linux". Not allowed to use the -c option with the Linux command for pattern...
-
You have been volunteered to oversee the graduation party at the end of the semester. Since the cost of the party is important and keeping costs down is imperative you need to pick 4 possible sites...
-
If my Free Cash Flow is 424 (in 2015), 534 (2016), 629 (2017), 586 (2018), 609 (2019), 364 (2020) What is my Present Value of the planning period? Other information for reference: NOPAT: 277, 315,...
-
Access the Federation of Tax Administrators Internet site at www. taxadmin.org/state-tax-forms and indicate the titles of the following state tax forms and publications: a. Minnesota Form M-100 b....
-
The following network is a compressed representation of the prospectus of a start-up firm that plans to develop a new, bio electronic computer chip. Note that four activities, the biological...
-
What could be some advantages and disadvantages of the following sources of information: (a) Charts, (b) Written reports, and (c) Firsthand observation?
-
Do you think that project evaluations cost-justify themselves?
-
Are there any potential problems with devoting most compensation dollars to rewarding top performers, even if this means neglecting investments to improve the welfare of all employees (such as day...
-
In examples of profit-sharing with employees, once the total pool is established, the business needs to develop a methodology for providing individual rewards that are clear, logical, and fair. If...
-
Class is divided into two groups. One group must defend and support the awarding of bonuses on the basis of annual financial targets. The second group needs to support a more complex range of goals,...
Study smarter with the SolutionInn App