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

Welcome: Shubham Agnihotri

This document provides an overview of Java fundamentals including variables, data types, operators, control statements, object-oriented programming concepts like classes, objects, inheritance, polymorphism, abstraction and encapsulation. It also discusses Java collection framework, exceptions handling, Hibernate, Git, HTTP methods and more. Key concepts covered are primitive vs non-primitive data types, arithmetic, relational and logical operators, classes and objects, inheritance, polymorphism, abstraction using interfaces and abstract classes, encapsulation using access modifiers, lists, sets, maps, checked vs unchecked exceptions and CRUD operations using HTTP methods.

Uploaded by

Prabhu 4u
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)
25 views

Welcome: Shubham Agnihotri

This document provides an overview of Java fundamentals including variables, data types, operators, control statements, object-oriented programming concepts like classes, objects, inheritance, polymorphism, abstraction and encapsulation. It also discusses Java collection framework, exceptions handling, Hibernate, Git, HTTP methods and more. Key concepts covered are primitive vs non-primitive data types, arithmetic, relational and logical operators, classes and objects, inheritance, polymorphism, abstraction using interfaces and abstract classes, encapsulation using access modifiers, lists, sets, maps, checked vs unchecked exceptions and CRUD operations using HTTP methods.

Uploaded by

Prabhu 4u
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/ 24

Welcome

Shubham Agnihotri
Java fundamentals

Basic of java:
Java variables
A variable is a container which can hold the value and type while the java program is executed. A
variable is assigned with a data type. A variable is the name of the memory location.
There are three types of variables in java:
1.local variables
2.Instance variables
3.Static variables
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
Primitive data types: The primitive data types include byte,short,int,long,float,double,char.
Non-primitive data types: The non-primitive data types include Arrays, Strings,Classes and Interfaces,.
Operators:

An operator is a symbol that operates on a value to perform specific mathematical or


logical computations.
➔ Arithmetic Operators
Arithmetic operators are +,-,*,/,%
➔ Relational Operators(>,<,>=,<=)
It checks expression and return true or false.
➔ Logical Operators(&&,||,!=)
It checks condition and return true or false
➔ Ternary Operators
Ternary operator is int variable = condition ? expression1:expression2;
➔ Assignment Operators
Assignment operator are =,+=,*=,-=;
a+=10 => a=a+10
Control statements:
Java Oops Concept:

Object:

Any entity that has state and behaviour is


know as object.A object is an instance of class
and it takes some space in the memory .

State:It represents the Attributes of an object.


Behaviour: it represents the methods of an
object.
Identity:it gives unique name of an object.
Class

Class is a set of objects which shares common characteristics and common properties. It is a just template of an
object and not a real world entity.
Class can have data members,methods,constructors.

Methods:
Collection of statements to perform specific task/action.
Methods have void or any specific return type.

Constructor:
● Constructor is used to create a instance of class
● Constructors are almost similar to methods except two
things, it’s name should be same as class name and it has
no return type.
Types:
Default constructor / No argument constructor
Parameterized constructor
Inheritance:

It is the mechanism in java by which one


class is allowed to inherit the features
(fields and methods) of another class.
The extends keyword is used for
inheritance in java.

Inheritance can be 3 type


1. Single Inheritance
2. Multilevel Inheritance
3. Hierarchical Inheritance
4. Multiple Inheritance
5. Hybrid Inheritance
Polymorphism:

Polymorphism allows us to perform a single


action in different ways.In other words,
polymorphism allows you to define one
interface and have multiple implementations.

Polymorphism main divided two types


Compile time polymorphism
Runtime polymorphism
Abstraction:
Data abstraction is the process of hiding certain details and showing only essential information to the
user,In java, abstraction is achieved by interfaces and abstract classes. We can achieve 100%
abstraction using interfaces.
● An abstract class is a class that is declared with an abstract keyword.
● An abstract class may or may not have all abstract methods. Some of them can be concrete
method
Encapsulation:
Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism
that binds together code and the data it manipulates. Encapsulation can be achieved by access
modifiers in java
Public:it can access the method or class anywhere in the project.
Private:it can access method with in the class
Protected:we can access the data with in the package
Collection:

Any group of individual objects which are represented


as a single unit is known as the collection of the objects.
In Java, a separate framework named the Collection
Framework has been defined,which holds all the
collection classes and interface in it.

Collection there mainly 3 three interfaces


➔ List Interface
➔ Set Interface
➔ Queue Interface
List Interface:

A list interface is stores the data in form Ordered collection.


it allows the duplicate values and List interface preserves the insertion order and It allow positional access
and insertion elements.

ArrayList :- It maintains the insertion order and can contain


duplicate elements.

Linked List :- It stores the data in sequential manner and


we can not access the data randomly.

Vector :- This is the legacy class and it is similar


to arraylist but only difference is that it is synchronized.

Stack :- It extends Vector class and mainly works last in first out structure.
Set Interface:

It is the child interface of Collection.


It is an unordered collection of objects in which duplicate values cannot be stored.
This interface contains the methods inherited from the Collection interface and adds a feature that
restricts the insertion of the duplicate elements.

HashSet :- it does not allow duplicate items. It does not maintain the insertion order. It allows null
value.

LinkedHashSet :- It is same to hashset but the only difference is that it maintains the sequence of
insertion.

TreeSet :- It stores the value in sorted manner and does not allow any null value.
Map interface:

Map interface represent key and value pair, map interface is not subtype collection interface A Map
cannot contain duplicate keys and each key can map to at most one value.
Hashmap:
It store the data(key and value ) pair to access
the values you must know the keys.
Syntax:
Map <String, Integer> data = new HashMap<>();

TreeMap:
It store the data (key and value) pair.
The advantage Tree Map sorted the keys and values.
Syntax:
Map <String,Integer> data =new TreeMap<>();
Git

Git is a Distributed Version Control System.Git helps


you keep track of the changes you make to your code.
There are four fundamental elements git workflow
working directory,staging directory,local repository
,remote repository .

The following commands are used


Git clone:To get the code form the server to your
local repository.

Git add:used to add a file that is in the working directory


to the staging area.
Git commands

Git commit:git commit is a command used to add all files that are staged to the local repository.

Git push:git push is a command used to add all committed files in the local repository to the remote
repository. So in the remote repository, all files and changes will be visible to anyone with access to
the remote repository.

Git fetch:is a command used to get files from the remote repository to the local repository but not
into the working directory.

Git merge: is a command used to get the files from the local repository into the working directory.

Git pull: is command used to get files from the remote repository directly into the working
directory. It is equivalent to a git fetch and a git merge .
Exception handling types

Checked Exception:
Checked exceptions are called compile-time exceptions because these exceptions are checked at
compile-time by the compiler.
1.ClassNotFoundException 2.FileNotFoundException
3.IO Exception 4.SQL Exception
Unchecked Exception:
These Exceptions Not checked by compile time,the program throws unchecked exception
Unchecked exception are
1.ArithmeticException b.NullPointerException
c.ArrayIndexOutOfBoundException d. ArrayStoreException
Error:
Errors are irrecoverable conditions such as Java virtual machine (JVM) running out of memory,
memory leaks, stack overflow errors, library incompatibility etc.
Exception Handling

Exception:
Exception is an unwanted or unexpected event,
which occurs during the execution of a program, i.e.
at run time, that disrupts the normal flow of the program’s
instructions. Exceptions can be caught and handled by
the program.
Try: block of code which exception can occur in that
Block.
Catch:The catch block contains code that is executed
if an exception handler is invoked.

Throw: this is the keyword throw an exception


Throws: the keyword declare the exception ,it specifies
That there may occur an exception this is method
Hibernate:

Hibernate is java framework that simplifies the development of a java application to interact with the database
and hibernate is a ORM(Object Relational Mapping).

Object relational mapping:


An ORM tool simplifies the data creation,
data manipulation and data access. It is a
programming technique that maps the object to
the data stored in the database.

Hibernate features:
● Hibernate primary feature is mapping the java class to database tables.
● Java data types to SQL data types
● Hibernate also provides data query and retrieval facilities .
● Hibernate provides independent Database query.
Different types of mapping:

@OneToOne:
Ex: One person have one pan card
@OneToMany
Ex:One customer have many accounts
@ManyToOne
Ex:Multiple employees are working on one Project
@ManyToMany
Ex: Many customer hava many orders.

Annotations:
@Entity: the class the related to database
@Table: name of the table name
@Id:generated by unique id
@Generated value: automatically increment id
@Column:specify the column name
HTTP Methods

HTTP PUT:
PUT replaces the old data resource with the new data resource.

HTTP Patch:
By this we can update one or two fields in the databases.

HTTP DELETE:
The http delete rest call Removes all current representations of the target resource given by a
URI.
HTTP Methods:

Client sends a request through http methods to get


response From the server.
These methods correspond to create,read,
update,Delete(CRUD) operations.

HTTP GET Method:


The GET method is used to retrieve information from
the Database using a given URI.

HTTP Post method:


Post Request is used send the data to database.
Type Casting

Type casting is when you assign a value of one primitive data type to another type.
Widening casting
Widening casting is done automatically when passing
a smaller size type to a larger size type
byte -> short -> char -> int -> long -> float -> double
Ex: int a = 9;
double b = a;
Narrowcasting
Narrowing casting must be done manually by placing the type in parentheses in front of the value
double -> float -> long -> int -> char -> short -> byte
Ex double a=20;
Int b = (int) a;
Generics

Generics means parameterized types.


The idea is to allow type (Integer, String, … etc.,
and user-defined types) to be a parameter to
methods, classes, and interfaces.

Advantages:
● Type Safety
● Code use
● Individual type casting not needed
Thank you!

You might also like