Explain the process of initializing an object

Assignment Help JAVA Programming
Reference no: EM13836048

1. Which method is invoked in a particular class when a method definition is overridden in several classes that are part of an inheritance hierarchy? Answer the question for the case in which the class has a definition for the method and also for the case where it doesn't.

2. Explain how assignments can be made within a class hierarchy and the role of casting in a class hierarchy. What is strong typing: Why is it an important language feature?

3. If Java encounters a method call of the following form:

superclassVar . met hodNarne

where superclassVar is a variable of a superclass that references an object whose type is a subclass, what is necessary for this statement to compile? During run time, will method methodName from the class that is the type of superclassVar always be invoked, or is it possible that a different method methodName will be invoked? Explain your answer.

4. Assume the situation in Question 3, but method methodName is not defined in the class that is the type of superclassVar, though it is defined in the subclass type. Rewrite the method call so that it will compile.

5. Explain the process of initializing an object that is a subclass type in the subclass con¬structor. What part of the object must be initialized first? How is this done?

6. 'What is the difference between the size and the capacity of an ArrayList? Why might we have a constructor that lets us set the initial capacity?

7. What is the difference between the remove (Object obj) and renove(int index) methods?

8. When we insert an item into an ArrayList, why do we start shifting at the last element?

9. The Vector and ArrayList both provide the same methods, since they both imple¬ment the List interface. The Vector has some additional methods with the same func¬tionality but different names. For example, the Vector addElement and add methods have the same functionality. There are some methods that are unique to Vector. Look at the Java API documentation and make a list of the methods that are in Vector that have equivalent methods in ArrayLi st and ones that are unique. Can the unique methods be implemented using the methods available in ArrayLi st?

10. If a loop processes n items and n changes from 1024 to 2048, how does that affect the running time of a loop that is 0(n2)? How about a loop that is 0(log n)? How about a loop that is 0(n log n)?

11. A veterinary office wants to store information regarding the kinds of animals it treats. Data includes diet, whether the animal is nocturnal, whether its bite is poisonous (as for some snakes), whether it flies, and so on. Use a superclass Pet with abstract methods and create appropriate subclasses to support about 10 animals of your choice.

12. A student is a person, and so is an employee. Create a class Person that has the data attributes common to both students and employees (name, social security number, age, gender, address, and telephone number) and appropriate method definitions. A student has a grade-point average (GM), major, and year of graduation. An employee has a department, job title, and year of hire. In addition, there are hourly employees (hourly rate, hours worked, and union dues) and salaried employees (annual salary). Define a class hierarchy and write an application class that you can use to first store the data for an array of people and then display that information in a meaningful way.

13. Develop a program to maintain a list of homework assignments. When an assignment is assigned, add it to the list, and when it is completed, remove it. You should keep track of the due date. Your program should provide the following services:
• Add a new assignment.
• Remove an assignment.
• Provide a list of the assignments in the order they were assigned.
• Find the assignment(s) with the earliest due date.

14. Write a program to manage a list of students waiting to register for a course as described in Section 2.5. Operations should include adding a new student at the end of the list, adding a new student at the beginning of the list, removing the student from the beginning of the list, and removing a student by name.

Reference no: EM13836048

Questions Cloud

Compare australia with any other advanced economy : Compare Australia with any other advanced economy and discuss their GDP last 2 to 5 years and factors affecting their GDP
How did the conflict in cora unashamed affect cora : How did the conflict in Cora unashamed affect cora
What is the southwest business model : What is the Southwest business model and why is it so effective? Is the "Continental Lite" and "Shuttle by United" achieving their objective of matching Southwest's price and service offering
Explain why we obseve flat upward sloping and inverted yield : State whether the following statements are True, False or Uncertain. Provide a short justification for your answer. (i) Bond A is a 5­year bond with a 9% coupon rate and a YTM of 9%. Bond B is a 15­year bond with a 8% coupon rate and a YTM of 10%. Bo..
Explain the process of initializing an object : Which method is invoked in a particular class when a method definition is overridden in several classes that are part of an inheritance hierarchy
Articulates the scens purpose and theme or argument : articulates the scene's purpose, theme or argument
How to create a format of a memo : Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 ..
The impact on equilibrium price and quantity of membership : Explain, with the use of demand and supply diagrams, the impact on equilibrium price and quantity of membership to health clubs from the simultaneous impact of an effective advertising campaign by the National Health Council and the reduction of comp..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a complete java program assuming that the variables gp

Write a complete java program Assuming that the variables gpa, deanList and studentName have been declared, you should read in the studentName and gpa from keyboard. Write an if statement that adds 1 to deansList and prints studentName to the standar..

  Write a program that prints a payroll statement

Write a program that accepts the subsequent information from the user and prints a payroll statement:

  Create a circle class

create acircle class, which has one field, the radius. the class should contains two constructors: a no-argument constructor that set the radius to zero, and a constructor that takes a parameter to set the radius.

  Implement an inheritance hierarchy based on the following

Implement an inheritance hierarchy based on the following specifications for Account class, Checking Account class, and Savings Account class Methods: processDeposit ( ) - accepts a single double parameter containing the deposit amount. Updates the ..

  Enterprise java beans (ejb) in software development

Enterprise Java Beans (EJB) in software development, EJB technology, EJB application, Stateless Session Beans (SLSB), Stateful Session Beans (SFSB), Message Driven Bean (MDB), Entity Bean

  Requirementspig is a folk jeopardy dice game with simple

requirementspig is a folk jeopardy dice game with simple rules two players race to reach 100 points. each turn a player

  Write a class array that encapsulates an array

Write a class Array that encapsulates an array and provides bounds-checked access. The private instance variables should be int index and inarray[10]. The public members should be a default constructor and methods (signatures shown below) to provide ..

  Write a program to display the customer''s name

Write a program that prompts the salesperson for the name of the customer and the price of the textbooks sold to that customer.• The program should display the customer's name and the total compensation

  Method that accepts a string object

Word Counter Write a method that accepts a String object as an argument and returns the number of words it contains. For instance, if the argument is "Four score and seven years ago" the method should return the number

  Writing a program that parses

The programming project involves writing a program that parses, using recursive descent, a GUI definition language defined in an input file and generates the GUI that it defines.

  Create a class safestack that implements a stack of strings

Create a class SafeStack that implements a stack of strings

  Create a project using the classes in the doc sharing area

create a project using the classes in the Doc Sharing area labeled A Simple LinkedList class. Compile it, run it, and review the code that is given carefully. This code tests the LinkedList class provided in the lecture.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd