• Have Any Queries +919677781155
  • Call : 1800 889 0145
  • info@elysiumacademy.org
  • Have Any Queries +919677781155
  • Call : 1800 889 0145
  • info@elysiumacademy.org
Logo (2)
  • About Us
    • Academy Overview
    • Mission & Vision
    • Foot Steps
    • Our Pillars
    • Gallery
    • Testimonials
      • Video Testimonials
      • Reviews
    • Our Awards
  • Tesbo Courses
      Tesbo Courses PREMIUM
      • Full Stack JS Programmer Course
      • Full Stack Core Programmer
      • Full Stack Native Programmer
      • Data Analyst CourseOFFER
      • Testing Expert CourseOFFER
      • Mobile App Developer Course
      • IT Infra Manager
      • Cloud Architect Course
      • DevOps Engineer Course
      • Digital Marketing CourseOFFER
      Slash CoursesBUDGET
      • Core C & C++ Coures
      • Core Java & Concepts Course
      • Core Python & Concepts Course OFFER
      • Core UI Development Course
      • Microsoft Office Course
      • CompTIA – Hardware A+ Course
      Classic Courses BUDGET
      • Core C & C++ Coures
      • Core Java & Concepts Course
      • Core Python & Concepts Course OFFER
      • Core MSSQL Course
      • Digital Marketing Courses
      mega-menu
  • Professional Course
      Professional Courses
      Programming Training
      • Programming Course TOP
      • Advanced Java Course
      • Advanced Python Course
      Full Stack Training
      • MERN Stack Course
      • MEAN Stack Course
      Mobile App Training
      • Android Course
      • IOS CourseOFFER
      • Flutter & Dart Course
      • React Native CourseOFFER
      Cyber Security Training
      • Hacking Defender Course
      • Security+ Course
      • Security Analyst+ Course
      • Elynux Essentials Course
      Networking Tranining
      • CCNA - Cisco Solutions
      • CCNP - Switching , Routing
      • Hardware A+ & Network N+
      DB Management Training
      • MySQL & MSSQL Course
      • Oracle DB Management
      Software Testing
      • ISTQB Course TOP
      • Automation Testing TOP
      Data Science & Analyst
      • Python for Data Science-ML
      • DA- (R,Tableau & Power BI)
      Cloud Computing Training
      • Cloud Practioner Course
      • Cloud Solution Architect Course
      • DevOps Professional Course
      • Cloud DevOps Engineer Course
      Crash Courses
      Programming Training
      • C++ Programming Course
      • Java Course OFFER
      • Python Course
      • UI Development Course
      • AngularJs Course
      • NodeJs Course
      • ReactJs Course
      • Wordpress Course
      • .Net Course TOP
      • Go Programming Course
      • Perl Programming Course
      • C# Programming CourseOFFER
      Business Management Course
      • Microsoft Office Course
      • Excel for Enterprises Course
      Testing Training
      • Selenium Java Course
      • Selenium Python Course
      Security Training
      • Hardware A+ Course
      • Cloud Associate Course
      • Azure Fundamental Course
      • Azure Administrator Course
      Digital Marketing Training
      • Digital Marketing Course
      • SMM Course TOP
      • PPC Expert Course
      • Advanced SEO Course
      • SMO Course OFFER
      DB Management Training
      • MSSQL Course
      • Core MYSQL OFFER
      • Oracle Fundamentals Course
      • Oracle DBA Course
      • Oracle PL SQL Course
      Professional Courses
      Programming Training
      • Programming Course TOP
      • Advanced Java Course
      • Advanced Python Course
      Full Stack Training
      • MERN Stack Course
      • MEAN Stack Course
      • Python Full Stack Course
      • Java Full Stack Course
      • PHP Full Stack Course
      • .Net Full Stack Course
      • JS Family Full Stack Course
      Mobile App Training
      • Android Course
      • IOS CourseOFFER
      • Flutter & Dart Course
      • React Native CourseOFFER
      Cyber Security Training
      • Hacking Defender Course
      • Security+ Course
      • Security Analyst+ Course
      • Elynux Essentials Course
      Networking Training
      • CCNA - Cisco Solutions
      • CCNP - Switching , Routing
      • Hardware A+ & Network N+
      DB Management Training
      • MySQL & MSSQL Course
      • Oracle DB Management
      Software Test Training
      • Software Test Expert Course TOP
      • Automation Testing TOP
      Data Science & Analyst
      • Python for Data Science-ML
      • DA- (R,Tableau & Power BI)
      Cloud Computing Training
      • Cloud Solution Architect Course
      • DevOps Professional Course
      • Cloud DevOps Engineer Course
      SAP Training
      • Finance & Controlling
      • Materials Management
      • Human Capital Management
      • Advanced Business App Programming
      • High-Performance Analytic Appliance
      Crash Courses
      Programming Training
      • C & C++ Programming Course
      • Java Course OFFER
      • Python Course
      • Core PHP Course
      • UI Development Course
      • AngularJs Course
      • NodeJs Course
      • ReactJs Course
      • Wordpress Course
      • .Net Course TOP
      • Go Programming Course
      • Perl Programming Course
      • C# Programming CourseOFFER
      Business Management Course
      • Microsoft Office Course
      • Excel for Enterprises Course
      Testing Training
      • Selenium Java Course
      • Selenium Python Course
      • Manual Tester - ISTQB Course
      Security Training
      • Hardware A+ Course
      • Cloud Associate Course
      • Azure Fundamental Course
      • Azure Administrator Course
      Digital Marketing Training
      • Digital Marketing Course
      • SMM Course TOP
      • PPC Expert Course
      • Advanced SEO Course
      • SMO Course OFFER
      DB Management Training
      • MSSQL Course
      • Core MYSQL OFFER
      • Oracle Fundamentals Course
      • Oracle DBA Course
      • Oracle PL SQL Course
      AI Mastery Program
      • AI Engineering For Developers
      • AI Power Digital Marketing
      • AI Mastery For Entrepreneurs Programme
  • Support
    • Placement Training
    • Career Guidance
    • Appointment Booking
    • Help Center
    • Tech Blog
    • Elysium Spark Notes
    • MicroBookShelf
    • Elysium CodeSheet
    • Interview Question
    • Download
    • Ask Elsa
    • Franchise Oppurtunity 
    • Classmate App
  • Contact Us
      • Madurai
      • Chennai - CIT Nagar
      • Tirunelveli
      • Virudhunagar
      • Perambalur
      • Trichy
      • Theni
      • Coimbatore - Hopes
      • Hosur
      • Tiruppur
      • Thoothukudi

      Contact Us

      • 227, IInd Floor, B Block, Elysium Campus, Church Rd, Anna Nagar, Madurai, Tamil Nadu 625020
      • 096777 81155, 096777 24437
      • +91 (0452) 4353702
      • info@elysiumacademy.org
      Madurai
      View More

      Contact Us

      • 12,North Road, near Nandhi Statue,CIT Nagar West, Chennai,Tamilnadu 600035
      • 9941161919
      • 089393 90929
      • chn.cit@elysiumacademy.org
      Chennai
      View More

      Contact Us

      • Castro Palace, 48/5, S Bypass Rd, Xavier Colony, Vasanth Nagar, Tirunelveli, Tamil Nadu 627005
      • 09488126688
      • tnv@elysiumacademy.org
      Tirunelveli
      View More

      Contact Us

      • 1/2A, AA Road, near Head Post Office, MGR Nagar, Anna Nagar, Virudhunagar, Tamil Nadu 626001
      • 08903390051
      • vnr@elysiumacademy.org
      Viruthunagar
      View More

      Contact Us

      • 1/2A, AA Road, near Head Post Office, MGR Nagar, Anna Nagar, Virudhunagar, Tamil Nadu 626001
      • 08903390051
      • vnr@elysiumacademy.org
      • Open 24 Hours
      Madurai
      View More

      Contact Us

      • 2nd Floor, Ponmanam Plaza, above Reliance Trends, near New Bus Stand, Thuraimangalam, Perambalur, Tamil Nadu 621212
      • +91 94422 20202
      • pbr@elysiumacademy.org
      Perambalur
      View More

      Contact Us

      • 2nd Floor, Jaishree Towers, C-142, 9A Cross Rd, above SBI Bank6th Cross East, Thillai Nagar East, West Thillai Nagar, Tennur, Tiruchirappalli, Tamil Nadu 620018
      • +91 9952887895
      • try@elysiumacademy.org
      tiruchy
      View More

      Contact Us

      • D. No.635/A, 3rd Floor, Near State Bank of India, Periyakulam Road, Theni
      • 78978 94002
      • 78978 95002
      • teni@elysiumacademy.org
      contact theni img
      View More

      Contact Us

      • 62, Suriya Complex, Gandhi Street, Thaneerpanthal Road, BR Puram, Hope College,
        Coimbatore -641 004. Landmark – Opp GRG School Ground
      • +91 96777 04758
      • +91 96777 04785
      • cbe.hopes@elysiumacademy.org
      contact cbe hopes img
      View More

      Contact Us

      • First Floor, No. 16, F/8, Hosur - Krishnagiri Rd, adjacent to Ameeria petrol bunk, Hosur, Tamil Nadu 635109
      • +91 99947 82270
      • hsr@elysiumacademy.org
      contact hosur img
      View More

      Contact Us

      • No.9/3C, Mariamman koil street, Padmavathipuram, SAP Theatre opposite, Tiruppur - 641603.
      • +91 7397391713
      • +91 7397391318
      • tup@elysiumacademy.org
      software training institutes
      View More

      Contact Us

      • 127, Ettayapuram Road, Melur Tuticorin, Tuticorin Central Police Station, Thoothukudi - 628002
      • +9193841 34008
      • +9193841 64008
      • ttk@elysiumacademy.org
      Contact -Tuticorin
      View More
  • About Us
    • Academy Overview
    • Mission & Vision
    • Foot Steps
    • Our Pillars
    • Gallery
    • Testimonials
      • Video Testimonials
      • Reviews
    • Our Awards
  • Tesbo Courses
      Tesbo Courses PREMIUM
      • Full Stack JS Programmer Course
      • Full Stack Core Programmer
      • Full Stack Native Programmer
      • Data Analyst CourseOFFER
      • Testing Expert CourseOFFER
      • Mobile App Developer Course
      • IT Infra Manager
      • Cloud Architect Course
      • DevOps Engineer Course
      • Digital Marketing CourseOFFER
      Slash CoursesBUDGET
      • Core C & C++ Coures
      • Core Java & Concepts Course
      • Core Python & Concepts Course OFFER
      • Core UI Development Course
      • Microsoft Office Course
      • CompTIA – Hardware A+ Course
      Classic Courses BUDGET
      • Core C & C++ Coures
      • Core Java & Concepts Course
      • Core Python & Concepts Course OFFER
      • Core MSSQL Course
      • Digital Marketing Courses
      mega-menu
  • Professional Course
      Professional Courses
      Programming Training
      • Programming Course TOP
      • Advanced Java Course
      • Advanced Python Course
      Full Stack Training
      • MERN Stack Course
      • MEAN Stack Course
      Mobile App Training
      • Android Course
      • IOS CourseOFFER
      • Flutter & Dart Course
      • React Native CourseOFFER
      Cyber Security Training
      • Hacking Defender Course
      • Security+ Course
      • Security Analyst+ Course
      • Elynux Essentials Course
      Networking Tranining
      • CCNA - Cisco Solutions
      • CCNP - Switching , Routing
      • Hardware A+ & Network N+
      DB Management Training
      • MySQL & MSSQL Course
      • Oracle DB Management
      Software Testing
      • ISTQB Course TOP
      • Automation Testing TOP
      Data Science & Analyst
      • Python for Data Science-ML
      • DA- (R,Tableau & Power BI)
      Cloud Computing Training
      • Cloud Practioner Course
      • Cloud Solution Architect Course
      • DevOps Professional Course
      • Cloud DevOps Engineer Course
      Crash Courses
      Programming Training
      • C++ Programming Course
      • Java Course OFFER
      • Python Course
      • UI Development Course
      • AngularJs Course
      • NodeJs Course
      • ReactJs Course
      • Wordpress Course
      • .Net Course TOP
      • Go Programming Course
      • Perl Programming Course
      • C# Programming CourseOFFER
      Business Management Course
      • Microsoft Office Course
      • Excel for Enterprises Course
      Testing Training
      • Selenium Java Course
      • Selenium Python Course
      Security Training
      • Hardware A+ Course
      • Cloud Associate Course
      • Azure Fundamental Course
      • Azure Administrator Course
      Digital Marketing Training
      • Digital Marketing Course
      • SMM Course TOP
      • PPC Expert Course
      • Advanced SEO Course
      • SMO Course OFFER
      DB Management Training
      • MSSQL Course
      • Core MYSQL OFFER
      • Oracle Fundamentals Course
      • Oracle DBA Course
      • Oracle PL SQL Course
      Professional Courses
      Programming Training
      • Programming Course TOP
      • Advanced Java Course
      • Advanced Python Course
      Full Stack Training
      • MERN Stack Course
      • MEAN Stack Course
      • Python Full Stack Course
      • Java Full Stack Course
      • PHP Full Stack Course
      • .Net Full Stack Course
      • JS Family Full Stack Course
      Mobile App Training
      • Android Course
      • IOS CourseOFFER
      • Flutter & Dart Course
      • React Native CourseOFFER
      Cyber Security Training
      • Hacking Defender Course
      • Security+ Course
      • Security Analyst+ Course
      • Elynux Essentials Course
      Networking Training
      • CCNA - Cisco Solutions
      • CCNP - Switching , Routing
      • Hardware A+ & Network N+
      DB Management Training
      • MySQL & MSSQL Course
      • Oracle DB Management
      Software Test Training
      • Software Test Expert Course TOP
      • Automation Testing TOP
      Data Science & Analyst
      • Python for Data Science-ML
      • DA- (R,Tableau & Power BI)
      Cloud Computing Training
      • Cloud Solution Architect Course
      • DevOps Professional Course
      • Cloud DevOps Engineer Course
      SAP Training
      • Finance & Controlling
      • Materials Management
      • Human Capital Management
      • Advanced Business App Programming
      • High-Performance Analytic Appliance
      Crash Courses
      Programming Training
      • C & C++ Programming Course
      • Java Course OFFER
      • Python Course
      • Core PHP Course
      • UI Development Course
      • AngularJs Course
      • NodeJs Course
      • ReactJs Course
      • Wordpress Course
      • .Net Course TOP
      • Go Programming Course
      • Perl Programming Course
      • C# Programming CourseOFFER
      Business Management Course
      • Microsoft Office Course
      • Excel for Enterprises Course
      Testing Training
      • Selenium Java Course
      • Selenium Python Course
      • Manual Tester - ISTQB Course
      Security Training
      • Hardware A+ Course
      • Cloud Associate Course
      • Azure Fundamental Course
      • Azure Administrator Course
      Digital Marketing Training
      • Digital Marketing Course
      • SMM Course TOP
      • PPC Expert Course
      • Advanced SEO Course
      • SMO Course OFFER
      DB Management Training
      • MSSQL Course
      • Core MYSQL OFFER
      • Oracle Fundamentals Course
      • Oracle DBA Course
      • Oracle PL SQL Course
      AI Mastery Program
      • AI Engineering For Developers
      • AI Power Digital Marketing
      • AI Mastery For Entrepreneurs Programme
  • Support
    • Placement Training
    • Career Guidance
    • Appointment Booking
    • Help Center
    • Tech Blog
    • Elysium Spark Notes
    • MicroBookShelf
    • Elysium CodeSheet
    • Interview Question
    • Download
    • Ask Elsa
    • Franchise Oppurtunity 
    • Classmate App
  • Contact Us
      • Madurai
      • Chennai - CIT Nagar
      • Tirunelveli
      • Virudhunagar
      • Perambalur
      • Trichy
      • Theni
      • Coimbatore - Hopes
      • Hosur
      • Tiruppur
      • Thoothukudi

      Contact Us

      • 227, IInd Floor, B Block, Elysium Campus, Church Rd, Anna Nagar, Madurai, Tamil Nadu 625020
      • 096777 81155, 096777 24437
      • +91 (0452) 4353702
      • info@elysiumacademy.org
      Madurai
      View More

      Contact Us

      • 12,North Road, near Nandhi Statue,CIT Nagar West, Chennai,Tamilnadu 600035
      • 9941161919
      • 089393 90929
      • chn.cit@elysiumacademy.org
      Chennai
      View More

      Contact Us

      • Castro Palace, 48/5, S Bypass Rd, Xavier Colony, Vasanth Nagar, Tirunelveli, Tamil Nadu 627005
      • 09488126688
      • tnv@elysiumacademy.org
      Tirunelveli
      View More

      Contact Us

      • 1/2A, AA Road, near Head Post Office, MGR Nagar, Anna Nagar, Virudhunagar, Tamil Nadu 626001
      • 08903390051
      • vnr@elysiumacademy.org
      Viruthunagar
      View More

      Contact Us

      • 1/2A, AA Road, near Head Post Office, MGR Nagar, Anna Nagar, Virudhunagar, Tamil Nadu 626001
      • 08903390051
      • vnr@elysiumacademy.org
      • Open 24 Hours
      Madurai
      View More

      Contact Us

      • 2nd Floor, Ponmanam Plaza, above Reliance Trends, near New Bus Stand, Thuraimangalam, Perambalur, Tamil Nadu 621212
      • +91 94422 20202
      • pbr@elysiumacademy.org
      Perambalur
      View More

      Contact Us

      • 2nd Floor, Jaishree Towers, C-142, 9A Cross Rd, above SBI Bank6th Cross East, Thillai Nagar East, West Thillai Nagar, Tennur, Tiruchirappalli, Tamil Nadu 620018
      • +91 9952887895
      • try@elysiumacademy.org
      tiruchy
      View More

      Contact Us

      • D. No.635/A, 3rd Floor, Near State Bank of India, Periyakulam Road, Theni
      • 78978 94002
      • 78978 95002
      • teni@elysiumacademy.org
      contact theni img
      View More

      Contact Us

      • 62, Suriya Complex, Gandhi Street, Thaneerpanthal Road, BR Puram, Hope College,
        Coimbatore -641 004. Landmark – Opp GRG School Ground
      • +91 96777 04758
      • +91 96777 04785
      • cbe.hopes@elysiumacademy.org
      contact cbe hopes img
      View More

      Contact Us

      • First Floor, No. 16, F/8, Hosur - Krishnagiri Rd, adjacent to Ameeria petrol bunk, Hosur, Tamil Nadu 635109
      • +91 99947 82270
      • hsr@elysiumacademy.org
      contact hosur img
      View More

      Contact Us

      • No.9/3C, Mariamman koil street, Padmavathipuram, SAP Theatre opposite, Tiruppur - 641603.
      • +91 7397391713
      • +91 7397391318
      • tup@elysiumacademy.org
      software training institutes
      View More

      Contact Us

      • 127, Ettayapuram Road, Melur Tuticorin, Tuticorin Central Police Station, Thoothukudi - 628002
      • +9193841 34008
      • +9193841 64008
      • ttk@elysiumacademy.org
      Contact -Tuticorin
      View More
Java Course

Java Programming

  • October 12, 2024
  • Com 0
Java-Programming

1. Java Basics

Java is a versatile and widely-used programming language that supports Object-Oriented Programming (OOP) principles. It is known for its portability across platforms (write once, run anywhere), robustness, and security.

Hello World Program:

Copy Code Copied Use a different Browser

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

Key Points:

  1. Class Declaration: Java programs are organized into classes, which contain the code. The keyword class defines a class.
  2. main() Method: The entry point of any Java application. It has the signature public static void main(String[] args).
  3. System.out.println(): A method to print output to the console.

2. Data Types

Java provides a wide range of data types, which are divided into primitive and non-primitive data types.

Primitive Data Types:

Data TypeSizeDefault ValueExample Usage
byte1 byte0byte b = 100;
short2 bytes0short s = 5000;
int4 bytes0int num = 12345;
long8 bytes0Llong l = 123456789L;
float4 bytes0.0ffloat f = 5.75f;
double8 bytes0.0ddouble d = 19.99;
char2 bytes\u0000char letter = ‘A’;
boolean1 bitfalseboolean flag = true;

Non-Primitive Data Types:

TypeDescriptionExample Usage
StringSequence of characters (class)String name = “Java”;
ArrayA fixed-size collection of valuesint[] nums = {1, 2};
ClassUser-defined objectDefined by developers

Example:

Copy Code Copied Use a different Browser

int age = 30;              // Primitive data type
String name = "John";      // Non-primitive data type (String class)
final int DAYS_IN_WEEK = 7; // Constant variable

3. Variables

Variables are containers for storing data. Java is a statically-typed language, meaning each variable must be declared with a data type.

Declaring Variables:

Copy Code Copied Use a different Browser

int age;            // Declaration
age = 25;           // Assignment
int height = 180;   // Declaration + Assignment
final double PI = 3.14159;  // Constant (unchangeable)

Variable Types:

  1. Local Variables: Declared inside methods, constructors, or blocks and used only within that scope.
  2. Instance Variables: Declared inside a class but outside methods, representing the state of an object.
  3. Static/Class Variables: Declared with the static keyword; shared among all objects of a class.

4. Operators

Java has various operators to perform operations on variables and values.

Arithmetic Operators:

OperatorDescriptionExample
+Additiona + b
–Subtractiona – b
*Multiplicationa * b
/Divisiona / b
%Modulus (remainder)a % b

Relational/Comparison Operators:

OperatorDescriptionExample
==Equal toa == b
!=Not equal toa != b
>Greater thana > b
<Less thana < b
>=Greater than or equala >= b
<=Less than or equala <= b

Logical Operators:

OperatorDescriptionExample
&&Logical ANDa && b
` `
!Logical NOT!a

Assignment Operators:

OperatorDescriptionExample
=Assign valuea = b;
+=Add and assigna += b;
-=Subtract and assigna -= b;
*=Multiply and assigna *= b;
/=Divide and assigna /= b;

Increment/Decrement Operators:

OperatorDescriptionExample
++Increment by 1a++ or ++a
—Decrement by 1a– or –a

 

5. Control Flow Statements

Control flow statements determine the flow of execution in a Java program. These include conditional statements, loops, and branching statements.

If-Else Statement:

Copy Code Copied Use a different Browser

if (age > 18) {
System.out.println("Adult");
} else if (age == 18) {
System.out.println("Just turned 18");
} else {
System.out.println("Minor");
}

Switch Case:

Copy Code Copied Use a different Browser

int day = 3;
switch (day) {
case 1: System.out.println("Monday"); break;
case 2: System.out.println("Tuesday"); break;
default: System.out.println("Another day");
}

Loops:

For Loop:

Copy Code Copied Use a different Browser

for (int i = 0; i < 5; i++) {
System.out.println(i);
}

While Loop:

Copy Code Copied Use a different Browser

int i = 0;
while (i < 5) {
System.out.println(i);
i++;
}

Do-While Loop:

Copy Code Copied Use a different Browser

int i = 0;
do {
System.out.println(i);
i++;
} while (i < 5);

Branching Statements:

StatementDescriptionExample
breakExits a loop or switch statementbreak;
continueSkips the current iterationcontinue;
returnExits the current method and returns a valuereturn value;

 

6. Arrays

Arrays in Java are used to store multiple values of the same type. They have a fixed size once declared.

 Array Declaration:

Copy Code Copied Use a different Browser

int[] numbers = {1, 2, 3, 4, 5};   // Array Initialization
int[] scores = new int[5];         // Declaring an empty array of size 5

Accessing Array Elements:

Copy Code Copied Use a different Browser

int firstNumber = numbers[0];   // Access first element
numbers[2] = 10;                // Modify third element

Iterating through Arrays:

Copy Code Copied Use a different Browser

for (int num : numbers) {
System.out.println(num);
}

Multidimensional Arrays:

Copy Code Copied Use a different Browser

int[][] matrix = { {1, 2, 3}, {4, 5, 6} };  // 2D Array
int value = matrix[0][1];  // Access element at row 0, column 1

7. Methods (Functions)

Methods allow reusability and modularity by grouping code into reusable blocks. Java supports both predefined methods (e.g., System.out.println()) and user-defined methods.

Defining Methods:

Copy Code Copied Use a different Browser

public static int add(int a, int b) {
return a + b;
}

Calling Methods:

Copy Code Copied Use a different Browser

int sum = add(5, 3);     // Method call
System.out.println(sum); // Output: 8

Method Overloading:

Method overloading allows methods to have the same name but different parameter lists (type, number, or order of parameters).

Copy Code Copied Use a different Browser

public int add(int a, int b) { return a + b; }
public double add(double a, double b) { return a + b; }

8. Object-Oriented Programming (OOP)

Java is an object-oriented programming language, which revolves around the following key concepts:

Classes and Objects:

A class is a blueprint for creating objects. An object is an instance of a class.

Class Definition:

Copy Code Copied Use a different Browser

class Dog {
String name;
int age;
void bark() {
System.out.println("Woof!");
}
}

Creating an Object:

Copy Code Copied Use a different Browser

Dog myDog = new Dog();    // Creating an object
myDog.name = "Buddy";     // Accessing fields
myDog.bark();             // Calling methods

Constructors:

A constructor is a special method used to initialize objects. It has the same name as the class and no return type.

Copy Code Copied Use a different Browser

class Dog {
String name;
int age;
// Constructor
Dog(String name, int age) {
this.name = name;
this.age = age;
}
}

Creating an Object with Constructor:

Copy Code Copied Use a different Browser

Dog myDog = new Dog("Buddy", 3);

Encapsulation:

Encapsulation is the concept of bundling data (fields) and methods that operate on that data into a single unit (class). The fields are made private, and access is provided through public getters and setters.

Copy Code Copied Use a different Browser

class Person {
private String name;
private int age;
public String getName() { return name; }
public void setName(String newName) { this.name = newName; }
}

Inheritance:

Inheritance allows a new class to inherit properties and behaviors (methods) from an existing class. The class being inherited from is called the superclass (parent), and the class inheriting is the subclass (child).

Copy Code Copied Use a different Browser

class Animal {
void eat() {
System.out.println("This animal eats food.");
}
}
class Dog extends Animal {
void bark() {
System.out.println("Woof!");
}
}

Using Inheritance:

Copy Code Copied Use a different Browser

Dog myDog = new Dog();
myDog.eat();    // Inherited from Animal class
myDog.bark();   // Defined in Dog class

Polymorphism:

Polymorphism allows objects of different classes to be treated as objects of a common superclass. It can occur through method overriding and method overloading.

Method Overriding:

Copy Code Copied Use a different Browser

class Animal {
void sound() {
System.out.println("Animal makes a sound");
}
}
class Dog extends Animal {
void sound() {
System.out.println("Woof!");
}
}
Animal myAnimal = new Dog();
myAnimal.sound();  // Outputs: Woof!

Abstraction:

Abstraction is the concept of hiding the internal details of an implementation and only exposing the essential features. In Java, abstraction is achieved using abstract classes or interfaces.

Abstract Class:

Copy Code Copied Use a different Browser

abstract class Animal {
abstract void sound();
void eat() {
System.out.println("This animal eats food.");
}
}
class Dog extends Animal {
void sound() {
System.out.println("Woof!");
}
}

9. Exception Handling

Java uses exceptions to handle runtime errors. Exceptions are objects that represent an error. Java uses the try-catch-finally mechanism for handling exceptions.

Try-Catch Block:

Copy Code Copied Use a different Browser

try {
int result = 10 / 0;  // This will throw ArithmeticException
} catch (ArithmeticException e) {
System.out.println("Cannot divide by zero!");
} finally {
System.out.println("This block always executes.");
}

Throwing Exceptions:

If you want to throw an exception manually, use the throw keyword.

Copy Code Copied Use a different Browser

if (age < 18) {
throw new IllegalArgumentException("Age must be 18 or older.");
}

Types of Exceptions:

  • Checked Exceptions: Exceptions checked at compile-time (e.g., IOException, SQLException).
  • Unchecked Exceptions: Exceptions not checked at compile-time but at runtime (e.g., NullPointerException, ArrayIndexOutOfBoundsException).

10. File Handling

File handling in Java is done using classes from the java.io package, such as File, Scanner, FileWriter, BufferedReader, etc.

Reading from a File:

Copy Code Copied Use a different Browser

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
File file = new File("filename.txt");
Scanner reader = new Scanner(file);
while (reader.hasNextLine()) {
String data = reader.nextLine();
System.out.println(data);
}
reader.close();

Writing to a File:

Copy Code Copied Use a different Browser

import java.io.FileWriter;
import java.io.IOException;
FileWriter writer = new FileWriter("filename.txt");
writer.write("Hello, File!");
writer.close();

Handling IOException:

Copy Code Copied Use a different Browser

try {
FileWriter writer = new FileWriter("filename.txt");
writer.write("Hello, File!");
writer.close();
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}

11. Packages and Imports

A package in Java is a namespace that organizes a set of related classes and interfaces.

Using Built-In Packages:

Copy Code Copied Use a different Browser

import java.util.Scanner;
Scanner input = new Scanner(System.in);
int age = input.nextInt();

Creating a Custom Package:

Copy Code Copied Use a different Browser

package myPackage;
public class MyClass {
public void displayMessage() {
System.out.println("Hello from MyClass");
}
}

Using the Custom Package:

Copy Code Copied Use a different Browser

import myPackage.MyClass;
public class Main {
public static void main(String[] args) {
MyClass obj = new MyClass();
obj.displayMessage();
}
}

12. Useful Java Libraries

Java comes with a vast set of libraries, also called APIs (Application Programming Interfaces), that provide a wide variety of functions.

String Manipulation:

  1. length(): Returns the length of the string.
  2. charAt(index): Returns the character at the specified index.
  3. substring(start, end): Returns the substring.
  4. indexOf(char): Returns the index of the first occurrence of the character.

Copy Code Copied Use a different Browser

String str = "Hello, Java!";
System.out.println(str.length());         // Output: 12
System.out.println(str.charAt(0));        // Output: H
System.out.println(str.substring(0, 5));  // Output: Hello
System.out.println(str.indexOf('J'));     // Output: 7

Collections Framework:

Java’s Collections Framework provides data structures like Lists, Sets, Maps, etc.

Copy Code Copied Use a different Browser

import java.util.ArrayList;
import java.util.HashMap;
ArrayList<String> names = new ArrayList<>();
names.add("Alice");
names.add("Bob");
HashMap<String, Integer> ages = new HashMap<>();
ages.put("Alice", 30);
ages.put("Bob", 25);

Date and Time API:

Java 8 introduced the java.time package, which provides better date and time manipulation capabilities.

Copy Code Copied Use a different Browser

import java.time.LocalDate;
import java.time.LocalTime;
LocalDate date = LocalDate.now();
LocalTime time = LocalTime.now();
System.out.println("Current Date: " + date);
System.out.println("Current Time: " + time);

13. Java Annotations

Annotations provide metadata about the code and do not change the program’s actual logic.

Common Annotations:

  1. @Override: Indicates that a method is overriding a superclass method.
  2. @Deprecated: Marks a method as deprecated (i.e., no longer recommended for use).
  3. @SuppressWarnings: Suppresses compiler warnings.

Copy Code Copied Use a different Browser

@Override
public String toString() {
return "Overriding the toString method";
}

14. Java Threads and Concurrency

Java provides built-in support for multithreading and concurrent programming through the Thread class and the Runnable interface.

Creating a Thread:

By Extending the Thread Class:

Copy Code Copied Use a different Browser

class MyThread extends Thread {
public void run() {
System.out.println("Thread is running");
}
}
MyThread thread = new MyThread();
thread.start();

By Implementing Runnable Interface:

Copy Code Copied Use a different Browser

class MyRunnable implements Runnable {
public void run() {
System.out.println("Runnable is running");
}
}
Thread thread = new Thread(new MyRunnable());
thread.start();

Concurrency Utilities:

Java provides higher-level concurrency APIs like ExecutorService, Callable, Future, etc., for handling multiple threads efficiently.

Copy Code Copied Use a different Browser

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
ExecutorService executor = Executors.newFixedThreadPool(2);
executor.submit(() -> {
System.out.println("Task 1");
});
executor.submit(() -> {
System.out.println("Task 2");
});
executor.shutdown();

15. Java Memory Management

Java provides automatic memory management with the help of Garbage Collection. The garbage collector reclaims memory used by objects that are no longer in use.

Memory Areas in Java:

  1. Heap: The runtime data area where objects are allocated.
  2. Stack: Stores method calls and local variables.
  3. Method Area: Contains class structure like metadata, methods, constants, and static variables.
  4. PC Registers: Program counter register, storing addresses of current instructions.

16. Java Design Patterns

Design patterns are reusable solutions to commonly occurring problems in software design. Some popular patterns in Java include:

Creational Patterns:

  • Singleton Pattern: Ensures that a class has only one instance.

Copy Code Copied Use a different Browser

public class Singleton {
private static Singleton instance;
private Singleton() { }
public static Singleton getInstance() {
if (instance == null) {
instance = new Singleton();
}
return instance;
}
}

  • Factory Pattern: Provides an interface for creating objects in a superclass but allows subclasses to alter the type of objects that will be created.

Copy Code Copied Use a different Browser

interface Shape {
void draw();
}
class Circle implements Shape {
public void draw() {
System.out.println("Drawing a Circle");
}
}
class Square implements Shape {
public void draw() {
System.out.println("Drawing a Square");
}
}
class ShapeFactory {
public Shape getShape(String shapeType) {
if (shapeType == null) return null;
if (shapeType.equalsIgnoreCase("CIRCLE")) return new Circle();
if (shapeType.equalsIgnoreCase("SQUARE")) return new Square();
return null;
}
}

Structural Patterns:

  1. Adapter Pattern: Allows incompatible interfaces to work together.
  2. Decorator Pattern: Allows behavior to be added to an individual object, dynamically.

Behavioral Patterns:

  1. Observer Pattern: Defines a one-to-many dependency between objects.
  2. Strategy Pattern: Allows algorithms to be selected at runtime.

17. Java Advanced Topics

Java Streams (Java 8):

Streams are used to process collections of objects. They support ope

Copy Code Copied Use a different Browser

interface MyFuncInterface {
void sayHello();
}
MyFuncInterface greet = () -> System.out.println("Hello, World!");
greet.sayHello();  // Output: Hello, World!

rations like filtering, mapping, and reducing in a declarative way.

Copy Code Copied Use a different Browser

import java.util.Arrays;
import java.util.List;
List<String> names = Arrays.asList("Alice", "Bob", "Charlie");
names.stream().filter(s -> s.startsWith("A")).forEach(System.out::println);  // Output: Alice

Lambda Expressions (Java 8):

Lambdas are anonymous functions that provide a concise way to represent instances of functional interfaces.

Copy Code Copied Use a different Browser

interface MyFuncInterface {
void sayHello();
}
MyFuncInterface greet = () -> System.out.println("Hello, World!");
greet.sayHello();  // Output: Hello, World!

Functional Interfaces (Java 8):

A functional interface has only one abstract method but can have multiple default or static methods. Some commonly used functional interfaces are Runnable, Callable, Supplier, Consumer, etc.

Copy Code Copied Use a different Browser

@FunctionalInterface
interface MyFuncInterface {
int add(int a, int b);
}
MyFuncInterface addition = (a, b) -> a + b;
System.out.println(addition.add(5, 3));  // Output: 8

18. Java Best Practices

  1. Follow Naming Conventions:
    1. Use camelCase for variables and methods (e.g., myVariable).
    2. Use PascalCase for class names (e.g., MyClass).
    3. Use ALL_CAPS for constants (e.g., MAX_VALUE).
  2. DRY Principle (Don’t Repeat Yourself):
    • Write reusable code by avoiding redundancy.
  3. Code Documentation:
    • Use comments and Javadoc for better readability and maintainability.
  4. Error Handling:
    • Catch specific exceptions and avoid using broad exception classes (e.g., avoid catch(Exception e) unless necessary).
  5. Immutable Classes:
    • Make classes immutable to improve thread safety.
  6. Avoid Memory Leaks:
    • Be cautious about object references, particularly in long-lived objects such as collections.

19. Conclusion

Java is a powerful, high-level programming language that has withstood the test of time due to its robustness, security, portability, and performance. This comprehensive has covered the fundamental and advanced aspects of Java, offering a valuable reference to both beginners and seasoned developers alike. From core language features like data types, operators, and control flow statements, to advanced topics like OOP principles, file handling, concurrency, and design patterns, Java continues to evolve, supporting modern development paradigms like functional programming and streams.

As you continue learning Java, explore the vast ecosystem of libraries, frameworks, and tools that extend Java’s capabilities. Whether you’re building enterprise-level applications, Android apps, or working with big data technologies like Hadoop and Spark, Java remains a top choice for developers worldwide. Happy coding!

Download Elysium Spark Note

Search

Latest Post

Thumb
Top 10 BCA Value Added Courses for
04 Jul, 2026
Thumb
Full Stack Development Course for B.Sc CS
04 Jul, 2026
Thumb
Value Added Courses for B.Sc CS Students:
03 Jul, 2026

Categories

  • ai training
  • Android
  • AWS Training and Certification
  • Azure & Microsoft Technologies
  • Azure Certification
  • azure devops
  • Azure DevOps training in Madurai
  • Azure Services
  • B.Sc Computer Science
  • Bachelor of Computer Application
  • Back End Development
  • Big Data Hadoop Training
  • big data revolution
  • Blog Post
  • C Online Course
  • C++ Programming
  • C++ Programming Course
  • Campus on Drive
  • Career Guidance Program
  • Career Opportunities
  • CCNA Certification
  • Cisco Training
  • Cloud Computing
  • Cloud Course
  • Cloud Courses Online
  • coaching classes near me
  • Coding Bootcamps & Courses
  • Computer Courses
  • Computer Engineering
  • Computer Hardware
  • Computer programming courses
  • Content Management Systems
  • Course
  • Cyber Security Course
  • Data Analyst Training course
  • Data Analytics Courses
  • Data Science & Analytics
  • Data science course
  • Database
  • Database Management
  • DevOps & Automation
  • Digital Advertising
  • Digital marketing academy
  • Digital Marketing Course
  • Digital marketing course online
  • Digital Marketing Strategies
  • Education & Learning
  • Education Training
  • Elysium Spark Note
  • Full Stack Developer Course
  • Go programming certification
  • Hacking Course
  • Hacking Defender Training Course
  • Hardware & Infrastructure
  • ISTQB Certification
  • IT Certifications
  • IT Networking Education
  • IT Training
  • IT Training Institute
  • Java Course
  • JavaScript Frameworks
  • Job Oriented Online Courses
  • Machine Learning
  • MEAN Stack Expert Training Course
  • MERN Stack Expert Training Course
  • Microsoft Access Training
  • Mobile App Development Courses
  • Networking & IT
  • Networking and Security
  • Networking Fundamentals
  • New Courses
  • Online Courses
  • Online Marketing Courses
  • Oracle Certification
  • Others
  • PPC Strategies
  • Productivity Software
  • Professional Certification Courses
  • Programming & Development
  • Programming Courses
  • Programming Courses
  • Programming Languages
  • Python Programming
  • Python Programming Course
  • React Programming
  • ReactJs Training Course
  • Selenium
  • Selenium computer training
  • Selenium Training
  • SEO Strategies
  • SEO Tools and Software
  • Social Media Marketing
  • Social media marketing course
  • Social Media Strategy
  • Software Development
  • Software Testing
  • Software testing Course Online
  • Software Training
  • Software Training Institute
  • SQL Training
  • Technology
  • Technology & IT Solutions
  • UI/UX Design
  • Uncategorized
  • User Experience (UX)
  • Web Automation
  • Web Designing Course
  • Web Development
  • Website Development
blog_card

Tags

100% job assurance courses advanced digital marketing course advanced Python course Android App Developer Android applications course Android Training aws certification Best Data science courses Best Data Science Courses Online with Certificates best data science institutes in Madurai Best full stack developer course Best full stack development training courses Best Java Course and Certification best Java courses Best Python Training and Certification Course Best Software Training Institutes Big Data Analytics Big Data Analytics training center Big Data Training career guidance career in Data Science cloud computing Data Science Best Institute elysium academy Ethical Hacking Course Excel Tips full stack course full stack developer full stack developer course fees full stack python developer full stack web development courses IT Training java course with certification Java Frameworks JavaScript Machine Learning Course Network Security Course Python certification course Python Developers Career Python Training and Certification Course training in Madurai training institute Video Training Course Web Development Course workshop
shape
shape-10
shape
EAPL

Unlock New Career Opportunities with an Accredited Certification from Elysium Academy

Get started now
Logo (2)

Elysium Academy provides students with highly effective coaching classes, delivered through immersive classroom sessions and the best teaching methodologies designed to yield valuable results. We take great pride in our identity and are honored to be a part of your business journey.

Icon-facebook Icon-linkedin2 Icon-instagram Pinterest X-twitter Icon-youtube

Company

  • About Us
  • Mission & Vission
  • Blog
  • Reviews
  • Environment Policy
  • Payment Method
  • Our Awards
  • Franchise Oppurtunity
  • Ask Elsa

Student Zone

  • Become an instructor
  • Video Reviews
  • Placed Students
  • Interview Questions
  • Appointment Booking
  • Career Guidance
  • Placement Training
  • Download
  • Help Center
Logo (2)

Elysium Academy provides students with highly effective coaching classes, delivered through immersive classroom sessions and the best teaching methodologies designed to yield valuable results. We take great pride in our identity and are honored to be a part of your business journey.

At Elysium Academy, we deliver high-impact coaching through immersive classroom experiences and advanced teaching methodologies tailored for measurable success. We take immense pride in our unique identity and are privileged to partner with you on your path to professional excellence.

Icon-facebook Icon-linkedin2 Icon-instagram Pinterest X-twitter Icon-youtube

Company

  • About Us
  • Mission & Vission
  • Blog
  • Reviews
  • Environment Policy
  • Payment Method
  • Our Awards
  • Franchise Oppurtunity
  • Ask Elsa

Student Zone

  • Become an instructor
  • Video Reviews
  • Placed Students
  • Interview Questions
  • Appointment Booking
  • Career Guidance
  • Placement Training
  • Download
  • Help Center

Our Branch Locations

  • Elysium Academy - Madurai , Anna Nagar
  • Chennai, CIT Nagar
  • Tirunelveli, Xavier Colony
  • Perambalur, Near New Bus Stand
  • Trichy,Thillainagar
  • Virudhunagar, Anna Nagar
  • Theni , NRT Nagar
  • Coimbatore - Hopes
  • Hosur
  • Tiruppur
  • Thoothukudi

Copyright © Elysium Academy | A Part of Elysium Groups

  • Cookie Policy
  • Terms & Condition
  • Terms of Use
  • Privacy Policy
Logo (2)