Uttaranchal University: Topic:Summer Internship Introduction To Java
Uttaranchal University: Topic:Summer Internship Introduction To Java
DEPARTMENT OF COMPUTER
SCIENCE
TOPIC :SUMMER INTERNSHIP
INTRODUCTION TO JAVA
• Introduction to java
• Syntax
• Features of java
• Types of data
• Object oriented programing language
• Application of java
• Project(flow chart)
• Certificate of the course
Execution of a java program:
INTRODUCTION TO JAVA
Java is high- level ,object -oriented programing language
initially developed by sun-microsystems. It was designed to
be a platform independence , meaning that java can be run
in any device or operating system like windows, mac, linux,
etc .. this platform independence is achieved through ”
write once run anywhere” approach ,in java source code is
compiled into bytecode and the it is executed by the JVM
(java virtual machine).
HISTORY:
Java was developed by James Gosling and his team at Sun
Microsystems in the mid-1990s. The first version, Java 1.0, was
released in 1996.
Over the years, Java has evolved with the introduction of new
versions and updates. Major releases include Java 2, Java SE
(Standard Edition), Java EE (Enterprise Edition), and Java ME
(Micro Edition). These editions cater to different application
development needs. Java SE is widely used for general purpose
programming.
• public class Main {
SYANTAX • public static void main(String[] args)
• { System.out.println("Hello World"); } }
NOTE
Every line of code that runs in Java must be inside a class
Any code inside the main() method will be executed.
Inside the main() method, we can use the println() method to print a line of text to the screen
System is a built-in Java class that contains useful members, such as out, which is
short for "output". The println() method, short for "print line", is used to print a
value to the screen (or a file).
FEATURES OF JAVA
•Dynamic: java supports dynamic memory allocation and garbage collection , simplifying memory management
•High performance: Java is faster than other traditional interpreted programming languages because Java
bytecode is "close" to native code. It is still a little bit slower than a compiled language
•Distributed java has libraries for creating distributed application allowing components to communicate over a
network
•Portable: javas “write once run anywhere “ capability makes it highly portable
TYPES OF DATA
Data Types : Data types specify the different sizes and values that can be
stored in the variable. There are two types of data types in Java:
1-PRIMITIVE 2-NON-PRIMITIVE
1- Boolean Data Type: The Boolean data type is used to store only two
possible values: true and false. This data type is used for simple flags that
track true/false conditions.
2- Byte Data Type: The byte data type is an example of primitive data
type. It is an 8-bit signed two's complement integer. Its value-range lies
between -128 to 127 (inclusive). Its default value is 0.The byte data type
is used to save memory in large arrays where the memory savings is most
required. It saves space because a byte is 4 times smaller than an integer.
3- Int Data Type: The int data type is a 32-bit signed two's complement
integer. Its value-range lies between - 2,147,483,648 (-2^31) to
2,147,483,647 (2^31 -1) (inclusive).. Its default value is 0.The int data type
is generally used as a default data type for integral values unless if there
is no problem about memory.
TYPES OF DATA
4-Long Data Type:
The long data type is a 64-bit two's complement integer. Its value-range lies between -9,223,372,036,854,775,808(-
2^63) to 9,223,372,036,854,775,807(2^63 )-Its default value is 0. The long data type is used when you need a range
of values more than those provided by int.
8-Short Data Type: The short data type is a 16-bit signed two's complement integer. Its value-range lies between -
32,768 to 32,767 (inclusive). Its minimum value is -32,768 and maximum value is 32,767. Its default value is 0.
The short data type can also be used to save memory just like byte data type. A short data type is 2 times smaller
OBJECT ORIENTED
PROGRAMMING LANGUAGE
OBJECT: An object is a basic unit of Object-Oriented Programming that represents real-life entities. A typical Java
program creates many objects, which as you know, interact by invoking methods.
Abstraction: Abstraction in Java refers to the concept of hiding complex details and only showing essential
information. It helps in simplifying code and making it more manageable.
abstraction is achieved by interface and abstract classes. We can achieve 100% abstraction using
interfaces.
The abstract method contains only method declaration but not implementation.
//abstract class
abstract class GFG{
//abstract methods declaration
abstract void add();
abstract void mul();
abstract void div();
}
INHERITANCE:
•Inheritance in Java allows a class to inherit properties and
behaviors from another class. It promotes code reuse .To
implement inheritance, we use the keyword "extends" to create a
subclass (child class) that inherits from a superclass (parent class).
•The subclass inherits all the non-private fields and methods of the
superclass and can also have its own additional fields and methods
•It also allows for method overriding, where the subclass can
provide its own implementation of a method inherited from the
superclass.
• This helps in organizing and structuring code, making it more
maintainable and scalable.
•example: 1.class Animal{
2.void eat(){
3.System.out.println("eating...");
4.}
5.}
6.class Dog extends Animal{
7.void bark(){System.out.println ("barking...");}
8.}
9.class TestInheritance{
10.public static void main(String args[]){
11.Dog d=new Dog();
12.d.bark();
POLYMORPHISM: Polymorphism in Java is a concept by which we can perform a single action in different ways.
Polymorphism is derived from 2 Greek words: poly and morphs. The word "poly" means many
and "morphs" means forms. So polymorphism means many forms.
SYNTAX:
1.class Bike{
2. void run(){System.out.println("running");}
3.}
4.class Splendor extends Bike{
5. void run()
{System.out.println("running safely with 60km");}
6.
7. public static void main(String args[]){
8. Bike b = new Splendor();//upcasting
9. b.run();
10. }
11.}
ENCAPSULATION: Encapsulation in Java is a mechanism that bundles data and methods together within a class, and
restricts direct access to the data from outside the class. It helps in achieving data hiding and
abstraction.
By declaring the instance variables of a class as private, we can control access to them. To access or
modify these variables, we use public getter and setter methods. This way, we can enforce validation
and ensure that the data is accessed and modified in a controlled manner.
2 Withdraw
CERTIFICATE OF THE COURSE
THANK YOU!