
Core Java Tutorials
Basics Core Java Programming
Java Components- JVM, JRE and JDK
Components are the features of java, which provides platform and environment to apply and implement java application.
- JVM: Jvm stands for Java Virtual Machine, which is used to interpret entire program line by line. This can handle the run time exception.
- JRE: JRE stands for Java Runtime Environment; It plays a key role while executing any java application.
- JDK : JDK stands for Java Development Kit, JDK is the Combination of J2EE, JSE, JME
- J2EE: Java Enterprise Edition (Which is useful for making Web Application)
- JSE: Java Standard Edition (Which is useful for network and securitypurpose)
- JME: Java Mobile Edition (which is useful for Mobile Applications).
Data Types and Variables
Data Types are used to store values in various platforms or data.
- It contains Primitive and Non-Promitive data types
- Primitive Data types: It contains Integer, Char, Float, Double, Long etc.
- Non Primitive Data types: It contains User- Defined Data Types.
Variables: Variables is the term which is having fixed values or pattern and it is liable to change.
For Example:
Int i=10;
Int – DataType, i-Variable, 10 -value
Methods
Methods are a term which is a collection of instructions. Methods can be public, private or protected.
For Example: Public void add()
Basic Programming
A High Level Programming which follows the rule BASIC.
Decision Statements
It is a structure, which have one or two conditions to be evaluated or tested by program, with statements that are to be executed if the condition is determined to be true or false.
For Example:
If(Condition(a>b))
{ //Statements
//System.out.println(“a is greater than b”);
}
Looping Statements
Looping statements are executing one or more statements several numbers of time. In java there are 3 types of loops while, do and for..
Syntax of while loop:
While(condition)
{
//statements
}
Syntax of do loop:
Do(condition)
{
//statements
}
Syntax of for loop
For(initialization; condition;increment)
{
}
OOPS in Java
Members of Class
Members of Class mean class members which you can put inside the class.
There are five types of members in java
- Inner class
- Initialization block
- Constructors
- Methods
- Variables
For Example:
You can not write as follows int a; a=5; because first one is okay but next statement i:e only assignment cannot be a member of a class,yea you can write int a=5 ; directly within a single statement.
Class and Object
Class is the most important part of oops programing. It is a template to make structure of entire program.
Object is a real word entity it contains and executed after class is created. Objects are created by new key word.
For Example: Object o=new Object
Constructors
Constructor is a method or block that’s called whenever object has been created, constructor does not have return type. Its name would be same as class name.
Has-A Relationship
Has-A Relationship is being used with Association to apply reusability process.
Is-A Relationship
It denotes “One object is type of another”, It denotes inheritance methodologies.
Constructor chaining
It is a method which is using to call one constructor with the help of another. It can be use this () keyword for constructors in the same class.
This statement
This is a reserved keyword in java. We cannot use this keyword as identifier. Its a reference variable that refers to the current object.
Super statement
super keyword is used to access methods of the parent class while this is used to a access methods of the current class. Its also used by class constructors to invoke constructors of its parent class.
Overloading and Overriding
Overloading refers to methods which can have same name but different parameters as well as different types.
Overriding refers to methods which can have same name , same signature and same types, it always been used with inheritance.
Abstract class and interface
Abstract class is the class which can implement all the methods in its subclasses. Interface is the blue print of class, which has default abstract methods, it doesnot have method signature or body. It does not have constructor.
Type Casting
Type casting is a procedure that converts an object or variable of one type into another.
Syntax
dataType variable name=(data type) Variabletoconvert
Abstraction
Abstraction can achieve 100% by using interface. Abstract Classes and methods, abstract class is a class that is declared with abstract keyword. An Abstract is a method that is declared without an implementation.
Polymorphism
Polymorphism is a principle of oops, that allow us to perform a single action in different way
Polymorphism have two type
- Compile time polymorphism
- Runtime Polymorphism
Access Specifiers
Access specifies are keywords of OOP, which sets the accessibility of classes, methods and other members. Mainly we use in oop are public, private and protected.
Encapsulation
Encapsulation is mechanisms which combines all the data and convert that data into single unit. It declares all the class members as private. It used methods called get() and set() methods.
Object Class
Object class is the parent class of the classes. Directly or indirectly all the class can be extends by Object class.
String Class
String class uses java.lang.String class package. It provides work on string methods and performs operations like trimming, comparing and converting.
Wrapper Class
Wrapper class is a class which converts primitive values into wrapper class object.
Scanner Class
Scanner class is a class in java.util package. It is the easiest way to read the entered data in java program. It uses predefined object system.in as parameter.
Collection Framework
Collection Framework is the most important concept in java. It provides a well organised architecture to group all the objects. Collection can perform searching, insertion, manipulation and deletion of data.
Collection framework contains following interfaces:
- List
- Queue
- Set
Collection framework contains following classes:
- ArrayList
- LinkedList
- Stack
- Vector
- PriorityQueue
- Hashset
- LinkedHasset
Exception Handling
Exception Handling is a procedure to avoid unwanted termination of java program. It handles upcoming exception at runtime. For to handle exception java use:
- Try
- Catch
- Throw
- Throws
- Finally