DEV Community

Cover image for java Features
Keerthana M
Keerthana M

Posted on Edited on

java Features

EXAMPLE PROGRAM:

public class Home{
public static void ( String args[]){
    System.out.println("hello");
}
}
Enter fullscreen mode Exit fullscreen mode

OUTPUT:
hello

Java Features:

OBJECT ORIENTED PROGRAMMING LANGUAGE:

  • OOPS in Java refers to Object-Oriented Programming System, which is built on four main principles:
  1. Encapsulation,
  2. Inheritance,
  3. Polymorphism,
  4. Abstraction.
  • These concepts help Java create modular, reusable, and maintainable applications.
  • OOPS (Object-Oriented Programming System) is a programming paradigm centered around objects that contain data (fields) and behavior (methods).
  • Java is inherently object‑oriented and uses OOPS to structure programs efficiently.

OOPS Concepts in Java

1. Class

  • A class is a blueprint for creating objects. It defines attributes and methods. Example: Car is a class; BMW is an object.

2. Object

  • An object is an instance of a class.
    It has:

  • State (data)

  • Behavior (methods)

  • Identity (unique memory reference)

3. Encapsulation

  • Binding data and methods together while restricting direct access using access modifiers.
  • Achieved using private fields and getter/setter methods.

4. Inheritance

  • Allows one class to acquire properties and behaviors of another class.

  • Promotes code reusability.

5. Polymorphism

  • Ability of a method or object to take many forms.
  • Compile-time polymorphism: Method overloading
  • Runtime polymorphism: Method overriding

6. Abstraction

  • Hiding internal implementation details and showing only essential features.
  • Achieved using abstract classes and interfaces.

CLASS:

  • Class is a container. (Blueprint, template.) Syntax:
Class Home{
   .......
   .......
}
Enter fullscreen mode Exit fullscreen mode
  • Class name must be meaningful.
  • Class name should start with uppaercase.
class Home{
public static void main (String[] args){
System.out.println("HELLO WORLD!!!!");
}
}
Enter fullscreen mode Exit fullscreen mode
  • {Home, System, string} are class in func.
  • No space between Class name.
    Eg: play ground

  • can use {$, _}

  • No special char allowed (except:$,_)

  • Number are allowed at mid or end of Class.

  • Not at the beginning of the classname.

class Home{
Static string name ="payilagam";
Static int addno=108;
//static keyword is used to store the class information is common for all and it take 1 memory space for whole class
public static void main(String[] args){
System.out.println(Home.name);
System.out.println(Home.age);
}
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)