16 solutions available
Question 1How does a class encapsulate state and behaviour?
Question 2Name the access specifiers available in Java.
Question 3Explain visibility in terms of the following access modifiers:publicprivateprotectedno modifier specified
Question 4Why is it a good idea to make all instance variables private?
Question 6Explain the scope of the following variables in Java:Local variablesParameter variablesInstance variablesClass variables
Question 7Explain the scope of variables in blocks and sub-blocks.
Question 8Is it legal to define local variables with the same identifier in nested blocks?
Question 9Why do you need to use static variables in Java?
Question 11What do you call a class that is an extension of another class?
Question 12What does the inheritance mechanism allow one class to acquire from another?
Question 13How is inheritance transitive? Explain.
Question 14Explain various types of inheritance.
Question 15Why do you need to use inheritance? Give two reasons.
Question 16Declare a public class CoolClass.Write the header for a public member method CoolMethodA.Write the header for an integer member method...
Question 5A member variable declared with no access specifier has visibility in ............... .Class and package onlyClass, package and subclass...
Question 10When many sub classes are inherited from a single base class, it is known as ............... .Hierarchical inheritanceMultiple...