0% found this document useful (0 votes)
12 views36 pages

Java Programming Overview and Features

Uploaded by

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

Java Programming Overview and Features

Uploaded by

deltabot046
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PROGRAMMING IN JAVA

MOHMMED SHANIL K P
S5 CSE
JAVA
• Java is an object oriented programming language.

• It was developed by James Gosling and rst released by Sun Microsystems in


1995.

• It is a “write once, run anywhere”(WORA) capability that makes it more


popular.

• It runs on all platforms with the help of the Java Virtual Machine (JVM).
fi
WHY JAVA
• Excellent educational resources

• Built-in libraries and functions

• Strong community assistance

• Excellent development tools

• Platform independent

• Safety
Simple Robust

Object Oriented Interpreted

Portable FEATURES High performance

Platform Independent OF JAVA Multi threaded

Secured Distributed

Architecture neutral Dynamic


APPLICATIONS OF JAVA
• Desktop GUI

• Web based programs

• Vedeo games

• Big data

• Mobile applications

• Desktop application
DEMERITS OF JAVA
• Slow

• Not attractive look

• No backup facility

• Require high memory space

• Complex codes
PROGRAMMING
IMPORT keyword brings classes
and entire packages into your
current source le, allowing you to
use them by their simple names
instead of their fully-quali ed
names.
fi
fi
IMPORT
[Link] a speci c class

Syntax : import [Link];

Example : import [Link];

[Link] all classes in a package

Syntax : import package.*;

Example : import [Link].*;


fi
[Link] import

Syntax : import static [Link];

Syntax : import static [Link].*;

Example : import static [Link];

import static [Link];


PACKAGES
In Java, a package is a mechanism for organizing related classes,
interfaces, and sub-packages into a structured hierarchy. It acts as a
container for grouping similar types of code, providing several bene ts:

Namespace Management

Access control

Code organisation and maintainability

Reusability

fi
TYPES OF PACKAGES
[Link]-in Packages

These are pre-de ned packages provided by the Java Development


Kit (JDK), such as [Link] (fundamental classes), [Link] (utility
classes), [Link] (input/output operations), and [Link] (Abstract Window
Toolkit for GUI).

[Link]-de ned Packages

Developers can create their own packages to organize their custom classes
and interfaces based on the application's structure and requirements.
fi
fi
In Java, a class serves as a blueprint or template for creating
objects. It de nes the structure and behavior that objects of
that class will possess. Classes are fundamental to Java's
object-oriented programming (OOP) paradigm.

In Java, an object is a fundamental concept in Object-Oriented


Programming (OOP), representing a speci c instance of a class.
fi
fi
CLASS & OBJECT
JAVA MAIN METHOD
Out put: The sum is: 30 Enter the rst number:10
Enter the second number:20
The sum is:30
fi
CONDITIONAL STATEMENTS
[Link]

The if statement executes a block of code only if a speci ed condition


evaluates to true. It can be extended with else and else if clauses to handle
alternative conditions.

• This can involve comparison operators (e.g., ==, !=, <, >, <=, >=) and logical
operators (e.g., &&, ||).

fi
Syntax :

if (condition) {

// Code to be executed if condition is true

} else if (anotherCondition) {

// Code to be executed if anotherCondition is true

} else {

// Code to be executed if none of the above conditions are true

}
Output:
Enter rst number:10
Enter second number:20
Enter third number:30
The largest number is:30

Largest of three numbers


fi
[Link]

The switch statement evaluates an expression and then executes the


code block associated with the matching case value. It provides a more
structured way to handle multiple possible execution paths based on a single
variable or expression.
Syntax: switch (expression) {

case value1:

// Code to be executed if expression matches value1

break; // Important to prevent "fall-through"

case value2:

// Code to be executed if expression matches value2

break;

default:

// Code to be executed if no case matches

}
CALCULATOR

Enter rst number: 10


Enter an operator(+,-,*,/): *
Enter second number:9
Output: Result : 90.0
fi
STRINGS
Output:

Enter a word: Heyy java

Number of letters:8

Letter counter
Manual functioning Using stringbuilder class
Output: Output:

Enter the string : Malayalam Enter the string : java

Original : malayalam Original : java

Reversed : malayalam Reversed : avaj

Palindrome Not Palindrome


FILE MANAGEMENT
[Link] is the main package to be imported it contains many classes that are
essential for le handling.

Important methods are:

• exists(): Checks if a le or directory exists.


• createNewFile(): Creates a new, empty le.
• delete(): Deletes a le or directory.
• read() / write(): Methods for reading and writing data (bytes or characters)
from/to streams.
• close(): Essential for releasing resources associated with le streams. Often
used within a nally block or a try-with-resources statement.
fi
fi
fi
fi
fi
fi
• try-with-resources: A language construct that ensures resources (like
le streams) are automatically closed, even if exceptions occur.
• try, catch, nally, throws: Keywords used for exception handling, crucial
when dealing with potential I/O errors.
fi
fi
Output:

File created: [Link]

Successfully wrote to the le.

File contents:

Hello, this is a simple le handling example in Java.

Deleted the le: [Link]


fi
fi
fi
GUI (Graphical User Interface)
A Graphical User Interface (GUI) enables users to interact with
digital devices through graphical elements like icons and
buttons.

[Link] & [Link] are the main packages to be imported when


dealing with GUI.

2D & 3D GUI can be created using java.


Output
THANK YOU

You might also like