Create a document using your favorite word processor

Assignment Help JAVA Programming
Reference no: EM131591632

Create a document using your favorite word processor and type your exercise solutions. At the top of the document be sure to include your name and the homework assignment number, e.g. HW2. Convert this document into Adobe PDF format and name the PDF file <asuriteid>.pdf where <asuriteid> is your ASURITE user id (for example, my ASURITE user id is kburger2 so my file would be named kburger2.pdf). To convert your document into PDF format, Microsoft Office versions 2008 and newer will export the document into PDF format by selecting the proper menu item from the File menu. The same is true of Open Office and Libre Office. Otherwise, you may use a freeware PDF converter program, e.g., CutePDF is one such program.

Next, create a folder named <asuriteid> and copy <asuriteid>.pdf to that folder. Copy any Java source code files to this folder (note: Java source code files are the files with a .java file name extension; do not copy the .class files as we do not need those).

Next, compress the <asuriteid> folder creating a zip archive file named <asuriteid>.zip. Upload <asuriteid>.zip to the Homework Assignment 2 by the assignment deadline. The deadline is in course schedule infor. Consult the online syllabus for the late and academic integrity policies.
Note: not all of these exercises will be graded, i.e., random ones will be selected for grading.

2 Learning Objectives
1. Properly use the public, private, and protected accessibility modifiers.
2. Write Java code to override and overload methods.
3. Recognize when inheritance is present among classes in an OOD.
4. Implement classes using inheritance.
5. To recognize when polymorphism is present in an inheritance hierarchy and to implement it.
6. To declare and implement a Java interface.
7. To implement a GUI.
3 Objects, Classes, and Inheritance
Is it required to provide an accessor and/or mutator method for every instance variable of a class? If yes, explain why this is required, and if no, explain why not.
Suppose the class Sub extends Sandwich. Which of the following statements are legal?
Sandwich x = new Sandwich(); Sub y = new Sub();
(a) x = y;
(b) y = x;
(c) Sub y = new Sandwich();
(d) Sandwich x = new Sub();
True or False? A subclass declaration will generally contain declarations for instance variables that are specific to object of that subclass, i.e., those instance variables represent attributes that are not part of superclass objects.
True or False? A superclass declaration will generally contain declarations for instance variables that are specific to objects of that superclass, i.e., those instance variables represent attributes that are not part of subclass objects.

Consider classes C1, C2, and C3. Answer the following questions.

class C1 {
public int x1; protected int x2; private int x3;
public void c1Method1() {} protected void c1Method2() {} private void c1Method3() {}
}

class C2 extends C1 { public int y1; protected int y2; private int y3;
public void c2Method1() {} protected void c2Method2() {} private void c2Method3() {}
}

class C3 extends C2 { public int z1; protected int z2; private int z3;
public void c3Method1() {} protected void c3Method2() {} private void c3Method3() {}
}

1. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c1Method1()?
2. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c1Method2()?
3. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c1Method3()?
4. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c2Method1()?
5. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c2Method2()?
6. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c2Method3()?
7. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c3Method1()?
8. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c3Method2()?
9. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c3Method3()?
10. Which instance variables y1, y2, y3 declared in C2 are directly accessible in c1Method1()?
11. Which instance variables y1, y2, y3 declared in C2 are directly accessible in c1Method2()?
12. Which instance variables y1, y2, y3 declared in C2 are directly accessible in c1Method3()?
13. Which instance variables z1, z2, z3 declared in C3 are directly accessible in c1Method1()?
14. Which instance variables z1, z2, z3 declared in C3 are directly accessible in c1Method2()?
15. Which instance variables z1, z2, z3 declared in C3 are directly accessible in c1Method3()?
16. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c2Method1()?
17. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c2Method2()?
18. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c2Method3()?
19. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c3Method1()?
20. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c3Method2()?
21. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c3Method3()?
22. Which instance methods c2Method1(), c2Method2(), c2Method3() are callable from c1Method1()?
23. Which instance methods c2Method1(), c2Method2(), c2Method3() are callable from c1Method2()?
24. Which instance methods c2Method1(), c2Method2(), c2Method3() are callable from c1Method3()?
25. How many instance variables are encapsulated within a C1 object?
26. How many instance variables are encapsulated within a C2 object?
27. How many instance variables are encapsulated within a C3 object?
Explain what an overloaded method is and give an example.
Explain what an overridden method is and give an example.
Explain what accidental overloading is and the preferred Java method for preventing it.
If an overridden method in a subclass needs to call the overridden superclass method, how is this accomplished?
True or False? It is legal for a method in a class to overload another method also in the same class. Explain.
True or False? It is legal in a class for a method to override another method also in the same class. Explain.
True or False? It is legal in a subclass for a method to overload a method in the superclass. Explain.
True or False? It is legal in a subclass for a method to override a method in the superclass. Explain.

True or False? It is legal in a superclass for a method to overload a method in a subclass. Explain.
True or False? It is legal in a superclass for a method to override a method in a subclass. Explain.
In a subclass constructor, the superclass default constructor is called automatically before the statements of the subclass constructor begin executing. Suppose we wish to call a different superclass constructor (i.e., not the default constructor) from the subclass constructor. Explain how this is accomplished and give an example.
Explain how an abstract class differs from a concrete class.
4 Objects, Classes, Polymorphism, and Interfaces
In the video lecture for Interfaces : Section 6 we discussed an example program that implements an inheritance hierarchy (Mammal is the superclass of Cat and Dog; Insect is the superclass of Cricket). Which method or methods in that program are called polymorphically?
Write the Java code to declare a new class Bee which is a subclass of Insect. The noise made by a Bee is "Buzz".
Write the Java code to declare a new abstract class Amphibian that implements the MakesNoise interface.
Write the Java code to declare a new class Frog which is a subclass of Amphibian. The noise made by a Frog is "Ribbet".
Modify the run() method of Main and add some Bees and Frogs to critters. Build your program and verify that it works correctly. Include all of your .java source code files in the zip archive that you submit for grading.

5 GUI Programming
For these exercises, include your completed .java files in the zip archive that you submit for grading. Complete the code in the provided View class to implement this GUI interface for a calculator. The calculator does not have to be fully functional; the primary objective of the assignment is to implement the GUI.

Create a document using your favorite word processor and type your exercise solutions. At the top of the document be sure to include your name and the homework assignment number, e.g. HW2. Convert this document into Adobe PDF format and name the PDF file <asuriteid>.pdf where <asuriteid> is your ASURITE user id (for example, my ASURITE user id is kburger2 so my file would be named kburger2.pdf). To convert your document into PDF format, Microsoft Office versions 2008 and newer will export the document into PDF format by selecting the proper menu item from the File menu. The same is true of Open Office and Libre Office. Otherwise, you may use a freeware PDF converter program, e.g., CutePDF is one such program.
Next, create a folder named <asuriteid> and copy <asuriteid>.pdf to that folder. Copy any Java source code files to this folder (note: Java source code files are the files with a .java file name extension; do not copy the .class files as we do not need those).
Next, compress the <asuriteid> folder creating a zip archive file named <asuriteid>.zip. Upload <asuriteid>.zip to the Homework Assignment 2 by the assignment deadline. The deadline is in course schedule infor. Consult the online syllabus for the late and academic integrity policies.
Note: not all of these exercises will be graded, i.e., random ones will be selected for grading.

2 Learning Objectives
1. Properly use the public, private, and protected accessibility modifiers.
2. Write Java code to override and overload methods.
3. Recognize when inheritance is present among classes in an OOD.
4. Implement classes using inheritance.
5. To recognize when polymorphism is present in an inheritance hierarchy and to implement it.
6. To declare and implement a Java interface.
7. To implement a GUI.

3 Objects, Classes, and Inheritance
Is it required to provide an accessor and/or mutator method for every instance variable of a class? If yes, explain why this is required, and if no, explain why not.
Suppose the class Sub extends Sandwich. Which of the following statements are legal?
Sandwich x = new Sandwich(); Sub y = new Sub();
(a) x = y;
(b) y = x;
(c) Sub y = new Sandwich();
(d) Sandwich x = new Sub();
True or False? A subclass declaration will generally contain declarations for instance variables that are specific to object of that subclass, i.e., those instance variables represent attributes that are not part of superclass objects.
True or False? A superclass declaration will generally contain declarations for instance variables that are specific to objects of that superclass, i.e., those instance variables represent attributes that are not part of subclass objects.

Consider classes C1, C2, and C3. Answer the following questions.

class C1 {
public int x1; protected int x2; private int x3;
public void c1Method1() {} protected void c1Method2() {} private void c1Method3() {}
}

class C2 extends C1 { public int y1; protected int y2; private int y3;
public void c2Method1() {} protected void c2Method2() {} private void c2Method3() {}
}

class C3 extends C2 { public int z1; protected int z2; private int z3;
public void c3Method1() {} protected void c3Method2() {} private void c3Method3() {}
}

1. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c1Method1()?
2. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c1Method2()?
3. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c1Method3()?
4. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c2Method1()?
5. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c2Method2()?
6. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c2Method3()?
7. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c3Method1()?
8. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c3Method2()?
9. Which instance variables x1, x2, x3 declared in C1 are directly accessible in c3Method3()?
10. Which instance variables y1, y2, y3 declared in C2 are directly accessible in c1Method1()?
11. Which instance variables y1, y2, y3 declared in C2 are directly accessible in c1Method2()?
12. Which instance variables y1, y2, y3 declared in C2 are directly accessible in c1Method3()?
13. Which instance variables z1, z2, z3 declared in C3 are directly accessible in c1Method1()?
14. Which instance variables z1, z2, z3 declared in C3 are directly accessible in c1Method2()?
15. Which instance variables z1, z2, z3 declared in C3 are directly accessible in c1Method3()?
16. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c2Method1()?
17. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c2Method2()?
18. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c2Method3()?
19. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c3Method1()?
20. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c3Method2()?
21. Which instance methods c1Method1(), c1Method2(), c1Method3() are callable from c3Method3()?
22. Which instance methods c2Method1(), c2Method2(), c2Method3() are callable from c1Method1()?
23. Which instance methods c2Method1(), c2Method2(), c2Method3() are callable from c1Method2()?
24. Which instance methods c2Method1(), c2Method2(), c2Method3() are callable from c1Method3()?
25. How many instance variables are encapsulated within a C1 object?
26. How many instance variables are encapsulated within a C2 object?
27. How many instance variables are encapsulated within a C3 object?
Explain what an overloaded method is and give an example.
Explain what an overridden method is and give an example.
Explain what accidental overloading is and the preferred Java method for preventing it.
If an overridden method in a subclass needs to call the overridden superclass method, how is this accomplished?
True or False? It is legal for a method in a class to overload another method also in the same class. Explain.
True or False? It is legal in a class for a method to override another method also in the same class. Explain.
True or False? It is legal in a subclass for a method to overload a method in the superclass. Explain.
True or False? It is legal in a subclass for a method to override a method in the superclass. Explain.

True or False? It is legal in a superclass for a method to overload a method in a subclass. Explain.
True or False? It is legal in a superclass for a method to override a method in a subclass. Explain.
In a subclass constructor, the superclass default constructor is called automatically before the statements of the subclass constructor begin executing. Suppose we wish to call a different superclass constructor (i.e., not the default constructor) from the subclass constructor. Explain how this is accomplished and give an example.
Explain how an abstract class differs from a concrete class.

4 Objects, Classes, Polymorphism, and Interfaces
In the video lecture for Interfaces : Section 6 we discussed an example program that implements an inheritance hierarchy (Mammal is the superclass of Cat and Dog; Insect is the superclass of Cricket). Which method or methods in that program are called polymorphically?
Write the Java code to declare a new class Bee which is a subclass of Insect. The noise made by a Bee is "Buzz".
Write the Java code to declare a new abstract class Amphibian that implements the MakesNoise interface.
Write the Java code to declare a new class Frog which is a subclass of Amphibian. The noise made by a Frog is "Ribbet".
Modify the run() method of Main and add some Bees and Frogs to critters. Build your program and verify that it works correctly. Include all of your .java source code files in the zip archive that you submit for grading.

5 GUI Programming
For these exercises, include your completed .java files in the zip archive that you submit for grading. Complete the code in the provided View class to implement this GUI interface for a calculator. The calculator does not have to be fully functional; the primary objective of the assignment is to implement the GUI.

762_figure1.jpg

Complete the code in actionPerformed() so when the Exit button is clicked, the application will terminate.

Complete the code in actionPerformed() so when the About button is clicked, the application will display this about dialog:

1302_figure2.jpg

Nested Classes
Explain what an inner class is.
Explain how a local class differs from an inner class.
Explain how an anonymous class differs from an inner and local class.

Reference no: EM131591632

Questions Cloud

Future value of multiple annuities assume : Future Value of Multiple Annuities Assume that you contribute $130 per month to a retirement plan for 20 years.
What is your rate of return on your investment : Suppose you buy 1,000 shares of Google at $300 per share. What is your rate of return on your investment?
What are the two components of common equity capital : What are the two components of common equity capital? How do the costs of the two differ?
Define and explain the contribution margin : In 400 words Define and explain the following: Contribution Margin and Contribution Margin Ratio
Create a document using your favorite word processor : Create a document using your favorite word processor and type your exercise solutions. At the top of the document be sure to include your name and the homework
New company wishes to install retirement plan : Your client the chief financial officer of a new company wishes to install a retirement plan
Calculate mystic mugs net income before taxes : Sanjog and Rajiv Gupta have started a business that manufactures and sells thermal mugs. Users personalize the mugs by plugging them into a laptop.
Were there any weaknesses in their analysis or conclusions : What reasoning process did the researchers use to formulate their conclusions? What explanation did they give to support their conclusions?
How your organization will know the program is successful : Provide a comprehensive description of how your organization (and potential funders) will know the program is successful.

Reviews

Write a Review

JAVA Programming Questions & Answers

  The desired functionality is for your programs to input

the desired functionality is for your programs to input pairs of natural numbers as theyre entered by the user until

  Explain the inventory program to include an add button

Modify the Inventory Program to include an add button, a delete button, and a modify button on the GUI. These buttons should allow the user to perform the corresponding actions on the item name, the number of units in stock

  Develop a complex web site

Develop a complex web site or piece of multimedia from scratch, using information gathering and design techniques;

  Employeeexception class whose constructor receives string

Create an EmployeeException class whose constructor receives a String that consists of an employee's ID and pay rate. Save the file as EmployeeException.java.

  Design and game loop with all the dummy functions

Design and game loop with all the dummy functions. During this module, implement one of the very first steps of Tetris, "Display the Bucket".

  Explain where the following method invocations

Explain where the following method invocations are most likely to be found in a program for dealing with census data organized using the Model, View, Controller (MVC) design pattern. Choices are zero or more of Model, View, and Controller. Be sure to..

  Write a program called inheritancetest java

Write a program called InheritanceTest.java to support an inheritance hierarchy for class Point-Square-Cube. Use Point as the superclass of the hierarchy. Specify the instance variables and methods for each class.

  Discuss the good and the bad of javascript libraries

Discuss the good and the bad of JavaScript Libraries. In what circumstances would you use Libraries? Describe what design measures you will incorporate in your web sites to assure web site security? Provide some examples.

  Computes the raise and new salary for an employee

Computes the raise and new salary for an employee. Complete the following program to determine the raise and new salary for an employee by adding if ... else statements to compute the raise

  Support for cloud-based strategies

In this course, you are introduced to general Windows Server concepts like active directory, group policy, security, networking and IIS, access control, and much more. Now that you understand the basic concepts, we will delve a little deeper and l..

  Describe the usefulness of the jframe class

What is a JFrame? Describe the usefulness of the JFrame class

  A method and using a synchronizedblock

What'sthe difference between synchronizing on a method and using a synchronizedblock?

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