0% found this document useful (0 votes)
12 views

module-1

The document provides an overview of Java programming fundamentals, including its architecture, key components like JVM, JRE, and JDK, and core concepts such as classes, objects, and strings. It explains the roles of JVM components, constructors, the 'this' keyword, and the finalize() method. The content is aimed at helping readers understand the foundational elements of Java programming.

Uploaded by

jayasri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

module-1

The document provides an overview of Java programming fundamentals, including its architecture, key components like JVM, JRE, and JDK, and core concepts such as classes, objects, and strings. It explains the roles of JVM components, constructors, the 'this' keyword, and the finalize() method. The content is aimed at helping readers understand the foundational elements of Java programming.

Uploaded by

jayasri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Java Programming Fundamentals

Architecture, Components, and Core Con


Java Architecture
• • Overview of Java architecture
• • Key Components: JVM, JRE, JDK

• Java Virtual Machine (JVM): Executes Java


bytecode.
• Java Runtime Environment (JRE): Provides
runtime environment.
• Java Development Kit (JDK): Tools for Java
development.
JVM Components
• • Class Loader: Loads class files
• • Bytecode Verifier: Checks code validity
• • Execution Engine: Executes bytecode
• • Garbage Collector: Manages memory
automatically.
Class and Object Fundamentals
• • Class: Blueprint for objects.
• • Object: Instance of a class.

• Example:
• class Car {
• String color;
• void start() {
• System.out.println("Car is starting");
• }
• }

• public class Main {


• public static void main(String[] args) {
• Car myCar = new Car();
• myCar.color = "Red";
• myCar.start();
• }
• }
String Classes
• • String class represents a sequence of
characters.
• • Common Methods: length(), substring(),
concat(), equals()

• Example:
• String str = "Hello, World!";
• System.out.println(str.length());
• System.out.println(str.substring(0, 5));
Constructors
• • Constructor: Initializes a new object.
• • No return type, same name as class.

• Example:
• class Person {
• String name;
• int age;
• Person(String name, int age) {
• this.name = name;
• this.age = age;
• }
• void display() {
• System.out.println(name + " is " + age + " years old.");
• }
• }

• public class Main {


• public static void main(String[] args) {
• Person p = new Person("Alice", 30);
• p.display();
• }
• }
This Keyword
• • 'this' keyword refers to the current object instance.
• • Used to differentiate between instance variables and parameters.

• Example:
• class Example {
• int value;
• Example(int value) {
• this.value = value;
• }
• void display() {
• System.out.println("Value: " + this.value);
• }
• }

• public class Main {


• public static void main(String[] args) {
• Example ex = new Example(10);
• ex.display();
• }
• }
finalize() Method
• • 'finalize()' is called before an object is garbage collected.
• • Allows cleanup before object is removed.

• Example:
• class Demo {
• @Override
• protected void finalize() throws Throwable {
• System.out.println("Object is being garbage collected");
• }
• public static void main(String[] args) {
• Demo obj = new Demo();
• obj = null;
• System.gc();
• }
• }
Summary
• • Java Architecture: JVM, JRE, JDK
• • JVM Components: Class Loader, Bytecode
Verifier, Execution Engine, Garbage Collector
• • Core Concepts: Classes, Objects, Strings,
Constructors, 'this' keyword, finalize() method
Questions
• Thank you!
• Any questions?
Thank You!

Thank you for your attention.


K. Srinivasrao
Assistant Professor, Aurora Deemed to be
University

You might also like