Java Tutorials – Java Class and Objects

CLASS AND OBJECTS
Source: Google

Java Class and Objects

In Java, everything revolves around a class. However, before moving on to more advanced Java topics, you should be familiar with the most basic OOP concepts, which are Java Class and Java Object.

Java Class and Objects are building blocks of java language.

An object is an instance of class whereas class is user define data type in Java.

A class defines the nature of an object, it is the foundation upon which all of Java is built. We’ve been using classes and objects since the beginning of this Java tutorial because all of the activities in a Java program take place within a class. Of course, those were very basic classes, but we didn’t take advantage of the majority of class features.

Objects :

An object is a recognizable entity with certain properties, states, and behavior. Because an object is simply a real-world entity, understanding the concept of objects is much easier when we consider real-life examples around us.

For example CAR is an Object.

Classes:

A class is user defined data type in java. It is group of objects which has similar properties and characteristics .

For example we can consider vehicle as class and it has various characteristics like speed, four wheels, shape. But we can say that BMW is a vehicle which is object in this case and it has all characteristics.

Java Class

The class is the foundation of Java’s Object orientation. A class is frequently refer to as an object’s blueprint or template. A class can be use to make multiple objects. It is a logical entity that takes up no physical space or memory. When we create objects of a class type, memory is allocate. A class contains properties and methods that define an object’s state and behaviour.

class and objects
Some Important Points to remember:
  • A top-level class cannot be declare as private in Java. For top-level classes, Java only allows public and default access specifiers. Inner classes can be mark as private.
  • We can take any types of variables in JAVA.
  • In a single program, there can only be one public class, and its name must match the name of the Java file. A single Java file can contain multiple non-public classes.
  • A public class is visible to any child in code.
  • Non-access modifiers for the class, such as final, abstract, and strict, can also be used.
  • We cannot declare class as final and abstract at the same time.

We have came to end of this blog. stay tuned for more upcoming blog on classes. http://mechomotive.com/java-tutorials-data-types-in-java/