Question

1.     When a sub class object is created, when is the call to the super class...

1.     When a sub class object is created, when is the call to the super class constructor made? How does a programmer call the super class constructor from the sub class?


What do all classes indirectly extend?
What methods does every class inherit from the Object class?

2.     When writing methods in a sub class, how can those methods call the methods from the parent class?

3.     Which class is more specific, a super class or a sub class?

4.     Can a super class have more than one sub class? What is an abstract class?

5.     Can an abstract class be instantiated?
Can an abstract class be used as a super class?

6.     If a class extends a superclass as follows: public class ClassA extends ClassParent Is the following a valid statement:

7.     ClassParent objectA = new ClassA( ); Is the following a valid statement?

8.     ClassA objectB = new ClassParent( );

9.     What is the difference between overriding a method and overloading a method?

10. Polymorphism

11. How does the JVM know which method to call when an object invokes a method? What is the purpose of the instanceof operator?
12. What data type does the instanceof operator evaluate to?
13. What is typecasting?

14. Protected and package specifiers

15. List the four Java access specifiers in order of least restrictive to most restrictive.

16.If you do not code an access specifier for a field or method, what is its default access?

17. Java interfaces

18. What code is contained in a Java interface?

19. All the method headings in a Java interface must have this access:
20. All the fields in a Java interface are: _________, _____________, and ___________. How many interfaces can a class implement?
21. What is meant by implementing an interface?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.Whenever a subclass object is created then the parent class default constructor will be called first followed by subclass constructor.

A super class parametrized constructor can be called by its subclass using super keyword as the first line in subclass constructor.

All classes extend the object class.

The methods which all the classes inherit from object class are clone(),equals(),finalize(),toString(),hashCode(),getClass()

2.Super keyword is used to call superclass methods from the childclass.
3.A superclass is more specific as it has all the attributes clearly defined which its childclasses need to extend.
4.Yes , a subclass can have more than one subclass.An abstract class is one which cannot be instantiated.
5.No, it cant be instantiated.Yes, it can be used as a superclass.
6.Yes
7.Yes it is a valid statement.
8.No, it is not a valid statement.
9.Overriding means having same method name in superclass and childclass whereas overloading means having same method name for more than one method
in same class but different number of parameters.
10.Polymorphism is ability of object to take on many forms.If an object passes more than one IS a test it is polymorphic.Most common example is parent class
reference with child class object.
11.JVM makes use of dynamic binding for instance methods and static binding for static methods to determine which method to call.
12.boolean datatype
13.Typecasting means converting from one datatype to other.
14.protected and package specifiers are used to limit the accessibility of classes.
15.public,default,protected,private.
16.Default
17.Interface is a collection of abstract methods.
18.Abstract methods,default methods,static variables etc.,
19.public
20.public,static and final.A class can implement multiple interfaces at once.
21.Implementing an interface means implementing all the methods present in the interface.

Add a comment
Know the answer?
Add Answer to:
1.     When a sub class object is created, when is the call to the super class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...

  • Abstract classes and Interfaces problems 10. Explain one similarity and one difference between ab...

    Abstract classes and Interfaces problems 10. Explain one similarity and one difference between abstract classes and interfaces. 11. Consider the following declarations. public interface Shape{ int someFunction(Shape other); //other functions not shown } public class Square implements Shape {/*implementation not shown*/} Which of the following function headings of someFunction must be added to the declaration of the Square class such that it will satisfy the Shape interface? public int someFunction (Shape other) public int someFunction (Square other) public boolean someFunction(Object...

  • Abstract classes and Interfaces problems 10. Explain one similarity and one difference between abstract classes and...

    Abstract classes and Interfaces problems 10. Explain one similarity and one difference between abstract classes and interfaces. 11. Consider the following declarations. public interface Shape{ int someFunction(Shape other); //other functions not shown } public class Square implements Shape {/*implementation not shown*/} Which of the following function headings of someFunction must be added to the declaration of the Square class such that it will satisfy the Shape interface? public int someFunction (Shape other) public int someFunction (Square other) public boolean someFunction(Object...

  • For Java, 1. What is an abstract method? How is an abstract method created? 2. What...

    For Java, 1. What is an abstract method? How is an abstract method created? 2. What is an abstract class? 3. Can an object of an abstract class be instantiated? 4. Does a superclass have access to the members of subclass? Does a subclass have access to the members of the superclass? 5. How do you prevent a subclass from having access to a member of a superclass? 6. Given the following hierarchy: class Alpha{ … class Beta extends Alpha...

  • Create an Item class, which is the abstract super class of all Items.           Item class...

    Create an Item class, which is the abstract super class of all Items.           Item class includes an attribute, description of type String for every item. [for eg. Book]                                                             A constructor to initialize its data member of Item class.               Override toString() method to return details about the Item class. Create the ExtraCharge interface with the following details.                       Declare a constant RATE with value 0.25   Declare a method called calculateExtraCharge(), which returns a double value. Create the...

  • (1)     ____ is the principle that allows you to apply your knowledge of a general category...

    (1)     ____ is the principle that allows you to apply your knowledge of a general category to more specific objects.           a.       Inheritance              c.       Encapsulation           b.       Polymorphism                    d.       Override (2)     When you create a class by making it inherit from another class, you are provided with data fields and ____ automatically.           a.       fonts                      c.       class names           b.       methods                  d.       arrays (3)     By convention, a class diagram contains the ____ following each attribute or...

  • JAVA: 1. What access modifier grants direct access to the super class members? 2. When a...

    JAVA: 1. What access modifier grants direct access to the super class members? 2. When a child class is created, when is the call to the parent class constructor made? 3. What is the keyword used to grant access to other classes that are in the same package?

  • Y. Daniel Liang’s 8 Class Design Guidelines were posted on the File Manager and handed out...

    Y. Daniel Liang’s 8 Class Design Guidelines were posted on the File Manager and handed out in class. Please choose 5 guidelines and discuss them in depth. For each guideline, use 1 page or more for your discussion. You can use the code provided in class to demonstrate your points. The code should not be more than one-third of your writing. 1. Cohesion • [✓] A class should describe a single entity, and all the class operations should logically fit...

  • Java True or false: The code shown on line 9 of the DividendStock class, super(symbol) illustrated...

    Java True or false: The code shown on line 9 of the DividendStock class, super(symbol) illustrated how a subclass can call its parents constructor. call Stock's getProtit method a methods share the same name, call stock's version. Again, you do this using the n have DividendStocks ger of its computation. However, since the two ant to you must explicitly tell the compiler that you w Here is the corrected code, which does compile and elma super keyword. redundancy / returns...

  • Question 1 Inheritance represents what type of relationship? Is-A Has-A Was-A Composition Flag this Question Question...

    Question 1 Inheritance represents what type of relationship? Is-A Has-A Was-A Composition Flag this Question Question 2 What is the keyword used to indicate a class inheritance relationship? Flag this Question Question 3 A sub class may not access any private members of the super class by name. True False Flag this Question Question 4 What is the keyword used by a sub class to call a super class constructor? Flag this Question Question 5 When we implement the method:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT