Welcome: Shubham Agnihotri
Welcome: Shubham Agnihotri
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:
Object:
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:
Stack :- It extends Vector class and mainly works last in first out structure.
Set Interface:
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 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.
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).
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:
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
Advantages:
● Type Safety
● Code use
● Individual type casting not needed
Thank you!