All Comments
TopTalkedBooks posted at August 20, 2017

Here is an explanation took from OCA Java SE 7 Programmer I Certification Guide: Prepare for the 1ZO-803 exam:

An object comes into the picture when you use the keyword operator new. You can initialize a reference variable with this object. Note the difference between declaring a variable and initializing it. The following is an example of a class Person and another class ObjectLifeCycle:

class Person {}
class ObjectLifeCycle {
    Person person;

In the previous code, no objects of class Person are created in the class ObjectLife-Cycle; it declares only a variable of type Person. An object is created when a reference variable is initialized:

class ObjectLifeCycle2 {
    Person person = new Person();

Syntactically, an object comes into being by using the new operator. Because Strings can also be initialized using the = operator, the following code is a valid example of String objects being created

class ObjectLifeCycle3 {
    String obj1 = new String("eJava");
    String obj2 = "Guru";
TopTalkedBooks posted at March 18, 2018

Taken from OCA Java SE 7 Programmer I Certification Guide: Prepare for the 1ZO-803 exam:


static variables belong to a class. They are common to all instances of a class and aren’t unique to any instance of a class. static attributes exist independently of any instances of a class and may be accessed even when no instances of the class have been created. You can compare a static variable with a shared variable. A static variable is shared by all of the objects of a class.


Static methods aren’t associated with objects and can’t use any of the instance variables of a class. You can define static methods to access or manipulate static variables

You can also use static methods to define utility methods, which are methods that usually manipulate the method parameters to compute and return an appropriate value

The non-private static variables and methods are inherited by derived classes. The static members aren’t involved in runtime polymorphism. You can’t override the static members in a derived class, but you can redefine them. Any discussion of static methods and their behavior can be quite confusing if you aren’t aware of inheritance and derived classes.

Top Books
We collected top books from hacker news, stack overflow, Reddit, which are recommended by amazing people.