Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here are some class definition with question that follow: public class BaseClass

ID: 3584787 • Letter: H

Question

Here are some class definition with question that follow: public class BaseClass { // methods of BaseClass } public SomeClass extends BaseClass { // methods of SomeClass } a. SomeClass scobj = new SomeClass(); b. BaseClass bcobj = scobj; c. SomeClass scobj = bcobj d.Bobj.aMethodOfSomeClass(); // does not exist in BaseClass A.Is statement b above legal, or casting required ? B.Statement is trying to assign the SomeClass object referred to by Bcobj to a SomeClass reference variable scobj2. What is wrong with this statement and would you fix it? C.In statement d, a BaseClass reference is trying to access a SomeClass class that is not part of BaseClass is this legal? Explain 5.Give example using Java snytax of how some class Y can be setup to inherit from some other class class X 6.What is significant difference between C++ and Java inheritance? 7.How is the keyword super used? Give two different uses for it and include Java examples. 8.Explain the difference between public, private, and protected access specifier. Give some guidelines of when each should be used. 9.Explain what package excess means and how it specified? 10.What can you do in Java to prevent a method for being overriden in a derived class? 11.How do you prevent a class from being extended? Give example code in your answer. 12.Explain how dynamic binding works in Java?

Explanation / Answer

Inheritance is a feature in object-oriented programming which is very similar to the way we inherit characteristics from our parents. Characteristics in object-oriented programming terms are attributes and behaviors of a class—that is, the data and methods of a class. Inheritance is a cornerstone of object-oriented programming because it enables objects to inherit attributes and behaviors from other objects, thereby reducing the amount of new code that must be designed, written, and tested each time a new program is developed.A hierarchical relationship develops as classes inherit from other classes within a program. Inheritance provides a way to distribute control for development and maintenance of objects. For example, a programmer might be responsible for creating and maintaining the student object. Another programmer might develop and maintain the graduate student object. Whenever a change occurs that affects all students, those changes are made to the student object and are then inherited by the graduate student object. Only the programmer responsible for the student object needs to address those changes because the graduate student object inherits any changes made to the student object. Inheritance also provides a way to limit access to attributes and behaviors. As we know public, private, and protected access specifiers are used to determine parts of the program that can access attributes and behaviors. Public access specifier is used to define members of a class that are available to other members of the class, other classes, and to all parts of the program. Private access specifier is used to define members that are only accessible by members of the same class only. They are unavailable to other classes and other parts of the program. The protected access specifier identifies attributes and behaviors that are available to members of the class and to other classes that are inherited from it. The purpose of limiting access to attributes and behaviors is to ensure the integrity of the object by controlling how other classes and parts of the program interact with it.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote