Java is one the most popular Programming Language used to create Web Applications and Platforms. It was designed for flexibility, allowing developers to write code that would run on any machine, regardless of architecture or platform. Java is used to build applications and platforms for number of devices, including computers, laptops, gaming consoles, car navigation systems, medical monitoring devices, parking metrics, lottery terminals and smartphones. It is also a key Language for networking, particularly for data centers that store and transfer Web-based data.
Another reason , which made Java popular is that it is an Object Oriented Programming Language. Being an Object Oriented Programming Language the concepts of Java are relatable and much flexible, system modular and extensible Programming Language. Java strongly suggests the best practices of OOP design and promotes it's correct usage. Once you have knowledge of key OOPS concept like Object, Class, abstraction, encapsulation, polymorphism and inheritance you can use all those with Java.
What is Class
In Java everything is encapsulated under classes. Class is the core of Java Language. Classe can be defined as a template or blueprint that describe the behaviors of a particular entity. A Class defines new data type. Once defined this new type can be used to create Object of that type. Object is an instance of Class, you may also call it as physical existence of a logical template class.
A class is declared using Class keyword. A class contain both data and code that operate on that data. The data or variables defined within a Class are called Instance Variables and the code that operates on this data is known as methods.
- A Class can have public or default access specifier.
- It can be either abstract, final or concrete (normal class).
- It must have the class keyword, class must be followed by a legal identifier.
- It may optionally extend one parent class. By default, it will extend java.lang.object.
- It may optionally implement any number of comma-separated interfaces.
- The class's variables and methods are declared within a set of curly braces {}.
- Each .java source file may contain only one public class. A source file may contain any number of default visible classes.
- Finally the source file name must match the public class name and it must have a .java suffix.
Syntax to Declare a Class
Suppose, Student is a Class and student's name, roll number, age will be it's property. Let's see the Syntax
class student.
{
string name;
int rollno;
}
What is an Object
An Object is nothing but a self-contained component which consists of methods and properties to make a particular type of data useful. In general words, An entity that has state and behavior is known as an Object e.g table, pen, bike, car, chair, building etc. It can be physical or logical (tangible and intangible). The example of intangible Object is Banking System.
An Object has Three Characteristics:
- State: Which represents data of an object.
- Behavior: Which represents the behavior of an object such as deposit, withdraw.
- Identity: Object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. But, it is used internally by the JVM to identify each object uniquely.
For e.g: Bike is an object. It's name is Pulsar 150, color is black known as state. It is used to Ride , so riding is it's behavior.
Syntax to declare an Object
class student.{
string name;
int rollno;
}
when a reference is made to particular student with it's property then it becomes an Object, physically existence of student class.
student std=new student();
The above statement std is instance/object of student Class. Here the new keyword creates an actual physical copy of the object and assign it to the std variable. It will have physical existence and get memory in help area. The new operator dynamically allocates memory for an object.
To Learn in detail about Java Programming Language and it's OOPS concepts, get Registered and Join the Course.
Training in core Java
For who want to create applications using Java Programming and Computing Language, a core Java certification Training is must. StudentZeal offers core Java Online and Classroom Training to Students who are keen to work as an Application Developer. This Training Provides a basic understanding of the Java Language.
No comments:
Post a Comment