Java Programming Overview

-If you do not provide an explicit call to super with arguments,the compiler provides a call to the super with no arguments,which results in calling a no-arguments constructor of the superclass.

-If you don't provide a no-argument constructor,the compiler makes call to the default no-argument constructor,which it provides itself.This will happen only if you have not defined any other constructor for the class;otherwise ,the compiler throws an error.

-An inherited class inherits all the fields and methods of its base class,except for its constructors.The constructor are strictly used by that base class only.

-The general rule is that if you want to detect an object type in an inheritance hierarchy,start with lowermost subclass and then move up the hierarchy to the base class.
example ;while using the instanceof operator .

-Whenever you create the subclass ,its parent class object is automatically created.

-With the extend keyword ,the subclass will be able to inherit all the properties of the superclass except the private properties.

-If you provide a constructor of your own-either no-argument one or one with arguments in the class definition-the compiler will not provide a default constructor.

-In string class--Clone method perform shallow copy and not deep copy.A shallow copy copies only the "surface' portion of an object.The actual object consists of this"surface",plus the all the objects are pointing to and so on.Copying entire web of objects is called a deep copy.

-A call to the this constructor must be the first statement int he implementation of the constructor.It cannot appear anywhere else.Therefore,you can have only one call to this,which must be first statement in the method body.If you call this ,you cannot call super because super cannot appear anywhere else other than the first statement.

-The overloading method differs by the number of the parameters or the  order of the parameters.

-The default implementation of the toString method returns an object reference.Many time developers override this method to print the object's state int the desired format.

-The first statement int he constructor may be call to to super or this.We use super to call the superclass constructor and use this to call some other class constructor defined within the same class.

-The final keyword can be used on class,a method or a variable.In general the use of final keyword restricts the further extensions or modifications.

-JVM creates all string literal objects in a dedicated memory pool and allocates the same reference to all strings having the same value.Therefore making the string class final makes sense so that java creators have ultimate control over the memory allocation used by the String type variables.

-If you do not want the subclass override your method implementation,you mark the method final.

-Because the private and static methods cannot be overridden in a subclass,they are always implicitly final.

-3 benefits by using final keyword
-----Explicitly preventing the overriding it in a subclass.(not to allow wait and notify methods system level methods that implement core language capabilities to modify from the Object class.)

-----final tells the compiler that a call to this method ,dynamic binding is not necessary,which potentially results in a slightly more efficient code.Static binding(compile time resolution) is more efficient than dynamic binding(runtime resolution of method call).

----marking a method final allows compile to turn any call tot hat method into an inline call.By which compiler will just replace the call with the actual method body avoiding all the overheads of storing method details on stack and popping out.

-A blank final variable must be initialized in a constructor because it is called only once during the object life cycle.If the final keyword is initialized in a constructor,it must be initialized in all overloaded constructors.

-If a final variable holds reference to an object,the reference must remain constant,not the object. We can change the object's state by invoking mutator methods on it.

-A final variable of the class type cannot refer to any object other than the object reference to which it has been set.





-

ref:Java Programming book by Poornachandra Sarang

-