Core Java Material1
Core Java Material1
qwertyuiopasdfghjklzxcvbnmqw
ertyuiopasdfghjklzxcvbnmqwert
yuiopasdfghjklzxcvbnmqwertyui
opasdfghjklzxcvbnmqwertyuiopa
sdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmrtyuiopasdfghjklzx
cvbnmqwertyuiopasdfghjklzxcvb
nmqwertyuiopasdfghjklzxcvbnm
qwertyuiopasdfghjklzxcvbnmqw
ertyuiopasdfghjklzxcvbnmqwert
yuiopasdfghjklzxcvbnmqwertyui
opasdfghjklzxcvbnmqwertyuiopa
sdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghj
klzxcvbnmqwertyuiopasdfghjklz
xcvbnmqwertyuiopasdfghjklzxcv
 Page No
 1. INTRODUCTION OF JAVA ………………………………………………………………1
 1.1.1. Platform independent
 1.1.2. Open source
 1.1.3. Multi-threading
 1.1.4. More secure
 1.1.5. portable
 2. CORE JAVA TOPICS ……………………………………………………………………...4
 2.1.1. Oops concept
 2.1.2. Control statement and looping
 2.1.3. Arrays
 2.1.4. String
 2.1.5. Collections
 2.1.6. Exceptions
 2.1.7. Constructor
4. ENCAPSULATION ………………………………………………………………………... 7
 5. INHERITANCE ……………………………………………………………………………. 7
 5.1.1. Single inheritance
 5.1.2. Multilevel inheritance
 5.1.3. Multiple inheritance
 5.1.4. Hybrid inheritance
 5.1.5. Hierarchical inheritance
 Page 1
6. ACCESS SPECIFIER
 …………………………………………………………………….. 9
 6.1.1. Public
 6.1.2. Private
 6.1.3. Protected
 6.1.4. Default
9. LOOPING …………………………………………………………………………………13
 9.1.1. For
 9.1.2. While
 9.1.3. Do-while
10. POLYMORPHISM…………………………………………………………………………17
 10.1.1. Method overloading
 10.1.2. Method overriding
11. ABSTRACTION…………………………………………………………………………...20
 11.1.1. Abstract class
 11.1.2. Interface
12. ARRAYS……………………………………………………………………………………22
13. STRING……………………………………………………………………………………..25
 13.1.1. String functions
 13.1.2. Literal string
 13.1.3. Non-literal string
 13.1.4. Mutable string
 13.1.5. Immutable string
14. COLLECTIONS……………………………………………………………………………26
 14.1.1. List
 14.1.2. Set
 14.1.3. Map
15. EXCEPTION………………………………………………………………………………59
Page 2
 15.1.1. Unchecked exception
 15.1.2. Checked exception
 15.1.3. Exception handling
16. CONSTRUCTOR…………………………………………………………………………73
JAVA INTRODUCTION
 1. Platform independent
 2. Open source
 3. Multithreading
 4. More secure
 5. Portable
1. Platform independent
  During the compilation the java program converts into byte code
  Using byte code we can run the application to any platform such as windows, mac, linux, etc
2. Open source:
  A program in which source code is available to the general public for use and/or modification from its original
 design at free of cost is called open source
3. Multithreading:
  Java supports multithreading
  It enables a program to perform several task simultaneously
4. More secure:
  It provides the virtual firewall between the application and the computer
  So it’s doesn't grant unauthorized access
5. Portable:
  "Write once run anywhere"
  Java code written in one machine can run on another machine
Page 3
 1. CORE JAVA
Syllabus:
 1. Oops concept
 2. Control statement/looping
 3. Arrays
 4. String
 5. Exceptions
 6. Collections
Terminology:
 1. JDK
 2. JRE
 3. JVM JDK:
JVM:
TOOLS:
 1. Notepad
 2. Net bean
 3. Eclipse
 4. J Developer-oracle
 5. RAD-IBM
  Nowadays we mostly used eclipse (75% of the people using).
  Versions of eclipse:  Juno
 • Kepler
 • Luna
 • Mars  Neon
 OOPS CONCEPT:
 Page 4
Oops principles are
 1. Class
 2. Method
 3. Object
 4. Abstraction
 5. Encapsulation
 6. Inheritance
 7. Polymorphism
CLASS:
 Class is nothing but collection of methods or collection of objects.  Project name : Should be in Pascal
 notation
 • Pascal notation : Each word of the first letter should be in
 capital
 • src - Source file
 • Class name: Pascal notation
 • Package creation: ex, org.cts.scope-All small letters
Syntax:
Public-Access specifier
METHOD:
Camel notation: First word should be small after every word of the first letter should be capital Syntax:
public void dummy() {
 // Here dummy is a method name
 } Main
Method:
public static void main(String[] args) {
OBJECT:
Page 5
  Run time memory allocation
  Using object we call the any methods Syntax:
2.ECommerce
public class OnlineShoppingSite { public
void myAccount() {
 System.out.println("Account Name");
 }
Page 6
 public static void main(String[] args) {
 OnlineShoppingSite info = new
OnlineShoppingSite(); info.catalog();
 info.myAccount(); info.orders();
 info.myWishList();
 }
}
Heap Memory:
ENCAPSULATION
  Structure of creating folders
INHERITANCE:
  We can access one class property into another class using 'extend' keyword and reusuable purpose
Types:
1. Single Inheritance
2. Multilevel Inheritance
3. Multiple Inheritances
4. Hybrid Inheritance
5. Hierarchical Inheritance
1. Single Inheritance :
 One parent class is directly support into one child class using extend keyword
2. Multilevel Inheritance:
Page 7
Child Class Parent Class Grand parent
3. Multiple Inheritance:
 More than one parent class parallely support into one child class but it won't suport in java because
1. Priority problem
(i.e) if both parent class having same method name it will get priority problem so it doesn;t work in java
test () test()
 test () is a method name, it present in both parent class, so its get priority problem
4.Hybrid Inheritance:
 Page 8
 Class A
Class B Class C
Class D
5. Hierarchical Inheritance:
Parent Class
ACCESS SPECIFIER:
 1. Public
 2. Protected
 3. Default
 4. Private
1. Public:
 Page 9
2. Private:
3. Default:
Ex,
4. Protected:
DATA TYPES:
 Data types Size Wrapper Class Default value
 byte 1 Byte 0
 short 2 Short 0
 int 4 Integer 0
 long 8 Long 0
 float 4 Float 0.0
 double 8 Double 0.0
 boolean - Boolean false
 char - Character -
 String - String null
-2^n-1 to +2^n-1 - 1
For byte,
1 byte =8 bits
 Page
 10
So n=8
Apply
symbol 'l'
Float
Symbol-‘f’ float
f=10.06f
Double:
b2=false;
 java.lang
 • bytenextByte();
 • shortnextShort();
 • intnextInt();
 Page
 11
 • longnextLong();
 • floatnextFloat();
 • doublenextDouble();
 • charnext().charAt(0);
 • Stringnext();
 • StringnextLine();
 • booleannextBoolean();
String:
String.s=sc.nextLine();
WRAPPER CLASS:
CONTROL STATEMENT:
 1. if
 2. if.else
 3. else.if variable name camel notation
Output valid
1. logical &&,// logical && check first condition if its fail it doesn't check second
 Page
 12
LOOPING:
 1. for
 2. while
 3. do.while For:
Example Program:
public class ForLoop { public static void
main(String[] args) {
System.out.println("Start"); for
(int i = 1; i <= 3; i++) {
 System.out.println(i);
 }
 System.out.println("End");
 }
}
output:
Start
End
Example Program:
public class InnerForLoop {
 public static void main(String[] args) {
 for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 6; j++) {
 System.out.print(i);
 }
 System.out.println();
 }}}
Output:
111111
222222
333333
444444
555555
 Page
 13
Println printline Break:
Program:
public class InnerForLoop { public static
void main(String[] args) {
 for (int i = 1; i <= 10; i++) {
 if (i == 5) {
 break;
 }
 System.out.println(i);
 }
 }}
Output:
Continue:
Program:
public class InnerForLoop { public static
void main(String[] args) { for
(int i = 1; i <= 10; i++) {
 if (i == 5) {
 continue;
 }
 System.out.println(i);
 }
 }
}
Output
 Page
 14
7
9 10
Example Program:
public class InnerForLoop { public static
void main(String[] args) { for
(int i = 1; i <= 20; i++) {
if (i % 2 == 0) {
System.out.println(i);
 }
 }
 }
} output
2
4
6
8
10
12
14
16
18
20
Program:
public class InnerForLoop { public static
void main(String[] args) { for (int
i = 1; i <= 20; i++) { if (i %
2 == 1) {
System.out.println(i);
 }
 }
 Page
 15
}
Output
1
3
5
7
9
11
13
15
17
19
Program:
public class SumofOddNum {
public static void main(String[] args) {
 int count=0;
 for(int i=1;i<=100;i++)
 {
 if(i%2==1){
 count=count+i;
 }
 }
 System.out.println(count);
}
}
Output:
2500
Program:
public class SumofOddNum { public static
void main(String[] args) {
 int count=0;
for(int i=1;i<=100;i++)
 {
 Page
 16
 if(i%2==0){
count=count+i;
 }
 }
 System.out.println(count);
}
}
Output:
2550
Factorial Numbers:
Example Program:
public class FactorialNumbers { public
static void main(String[] args) {
 int count=1;
for(int i=1;i<=8;i++){
count=count*i;
 }System.out.println(count);
 }
}
Output:
40320
POLYMORPHISM:
  Poly-many
  Morphism-forms
  Taking more than one forms is called polymorphism or one task completed by many ways
It has 2 types,
1.Method overloading:
 Class-same
 Method-same
 Argument-differ
  In a same class method name is same and the argument is different is called method overloading
  the argument is depends on
 • data types
 • data types count
 • data type order Example Program:
 Page
 17
public class StudentInfo {
 private void studentId(int num) {
 }
 private void studentId(String name) { \\ depends on order
 }
 private void studentId(String email, int ph) { \\depends on data type
 }
 private void studentId(int dob, String add) { \\depends on datatype count
 }
 public static void main(String[] arg) {
 StudentInfo info = new StudentInfo();
 }
}
  In the same method the argument can't use int and byte because int &byte both are numbers. so
 it doesn't work.
  public void employeeID(int num, byte num2) is not correct
2.Method overriding:
Method-same
Argument- same
  In a different class , the method name should be same and argument name should be same is
 called overriding Example Program:
output : ramya;
 The same method name in both class it take sub class only
 Page
 18
  If we satisfied with super class we go for super class method but we won't satisfy with super
 class we go for sub class method
  We can assign our sub class to our super class but can't reverse
Example Program:
Output: Hello
Output: Hello
ABSTRACTION:
2.Fully abstraction(interface)
 Page
 19
  We can’t create object for abstract class because in the method signature we didn't mention any
 business logic. so
  In abstract method, we only mention abstract signature, won't create business logic
  It have 2 class, abstract class(sub class) and super class. we create object and business logic only
 in super class, won't create in abstract class
Example Program:
abstract class
public abstract class Bank {
 abstract void saving(); //method signature
 abstract void current();
abstract void salary(); abstract
void joint(); public void
branchDetails(){
 System.out.println("chennai");
 }
}
super class
public class AxisBank extends Bank {
 public void saving() { // method signature
System.out.println("saving regular"); // business logic
}
public void current() {
 System.out.println("current");
}
public void salary() {
 System.out.println("salary");
}
public void joint() {
 System.out.println("joint");
}
public static void main(String[] args) {
AxisBank info = new AxisBank();
info.branchDetails(); info.salary();
info.saving();
}} Output:
chennai
salary saving
regular
2. INTERFACE/FULLY ABSTRACTION;
 Page
 20
interface
public interface Bank { abstract
void saving(); abstract void
current(); abstract void
salary(); abstract void
joint(); public void
branchDetails();
}
super class
public class AxisBank implements Bank {
 public void saving() {
 System.out.println("saving regular");
}
 public void current() {
 System.out.println("current");
 }
 public void salary() {
 System.out.println("salary");
 }
 public void joint() {
 System.out.println("joint");
 }
 public void branchDetails() {
 System.out.println("chennai");
 }
 public static void main(String[] args) {
 AxisBank info = new AxisBank();
 info.branchDetails();
 info.salary();
 info.saving();
}
}
 Output:
chennai
salary saving
regular
 multiple inheritance its won’t support in java but using interface its support
 here we have to create 2 interface(super class) and one sub class(normal). In the sub class we
 implement both interface Example Program:2
interface
public interface AxisBank { public
void test();
}
public interface HdfcBank {
public void test();
}
 Page
 21
sub class(normal class)
public class Bank implements AxisBank, HdfcBank{
 @Override public
void test() {
 // TODO Autogenerated method stub
 }
}
Abstract class:
  It is partially abstraction
  It support both abstract method and non-abstract method
  It’s using "extends" keyword
  Here "public abstract" have to mention
  We can use whatever access specifier we want Interface:
  It is fully abstraction
  It support only abstract method
  It’s using "implement" keyword
  "public Abstract" is default. no need to mention
  Here we use only public( access specifier)
ARRAYS:
Syntax:
Here, int 
 variable []
 Array
5 Array length
 Page
 22
 }
}
Output: 0
  If we didn't assign any value, it will takes the default value of data types(int)  Default value of
int is 0 Example Program:
public class BasicArray {
 public static void main(String[] args) {
 int num[]=new int[5];
num[0]=10; num[1]=20;
num[2]=30; num[3]=40;
num[4]=50;
 System.out.println(num[2]);
}
}
Output: 30
300
 Page
 23
num[1]=20; num[2]=30;
num[3]=40; num[4]=50;
 num[2]=300;
 for(int i=0;i<num.length;i++)
 System.out.println(num[i]);
}
}
Output:
10
20
300
40 50
Enha
nced
for
loop:
syntax:
for(int k:num)
System.out.println(k); Example
Program:
public class BasicArray { public static
void main(String[] args) { int
num[]=new int[5]; num[0]=10;
num[1]=20; num[2]=30;
num[3]=40; num[4]=50;
num[2]=300; for(int k:num)
 System.out.println(k);
}
} Output:
10
20
300
40
50
 Page
 24
  In this enhanced for loop, have no condition checking and value assign  It is very fast compare
to normal for loop Advantage of array:
STRING:
  Collections of charactor or word enclosed with double quotes
Basic Topics:
 • String function
 • Mutable string
 • Immutable string Example Program:
public class StringBasic {
 public static void main(String[] args) {
 String s1="Vengat";
 System.out.println(s1);
 }
} Output: Vengat
charAt():
Output:
Vengat n
 Page
 25
public class StringBasic {
 public static void main(String[] args) {
 String s1 = "Vengat";
System.out.println(s1); boolean b =
s1.equals("Vengat");
System.out.println(b); boolean b1 =
s1.equals("vengat");
System.out.println(b1);}}
Output:
Vengat
true false
Equalsignorecase():
Program:
public class StringBasic {
 public static void main(String[] args) {
 String s1 = "Vengat";
System.out.println(s1); boolean b =
s1.equals("Vengat");
System.out.println(b);
 boolean b1 = s1.equalsIgnoreCase("vengat");
 System.out.println(b1);
}}
Output:
Vengat
true true
contains():
 Contains() is a method , is used to check the particular character or word in the string Example
Program:
public class StringBasic { public static void
main(String[] args) { String s1 = "Hello
welcome to java class";
System.out.println(s1); boolean b =
s1.contains("welcome");
 System.out.println(b);
 }
}
Output:
 Page
 26
  If we check other than the string index, it shows false
Example Program:
public class StringBasic { public static void
main(String[] args) { String s1 = "Hello
welcome to java class";
System.out.println(s1); boolean b =
s1.contains("welcome"); System.out.println(b);
 boolean b1 = s1.contains("hai");
 System.out.println(b1);
 }
}
Output:
 split() is a method, is used to split the string by space or character or word or whatever Example
Program:
public class StringBasic { public static void
main(String[] args) { String s1 = "Hello
welcome to java class";
 String[] x = s1.split(" "); // here we split by space
 System.out.println(s1.length());
 System.out.println(x.length);
 String[] x1 = s1.split("o"); // here we split by "o"
 System.out.println(s1.length());
 System.out.println(x1.length);
 }
}
Output:
 Page
 27
 }
} Output:
Hello
welcome
to java
class
Output: Hello
welcome
toLowerCase():
HELLO
subString();
 It is used to print from, which character we want in the string index Example
Program:
 Page
 28
public class StringBasic { public static
void main(String[] args) {
String s1 = "Hello java";
 String m = s1.substring(2);
 System.out.println(m);
 String m1 = s1.substring(2, 6);
// upto
 System.out.println(m1);
 }}
Output:
indexOf():
 Page
 29
Output:
4
-1 7
lastIndexof():
Program:
public class StringBasic { public static
void main(String[] args) { String
s1 = "Hello java";
 int m = s1.indexOf("o"); // "o", to print o position
 System.out.println(m);
 int m1 = s1.indexOf("b"); // "b" is not in the string, so it print "1"
 System.out.println(m1);
 int m2 = s1.indexOf("a"); // multiple character "a", it takes first
one System.out.println(m2);
 int m3 = s1.lastIndexOf("a"); // multiple character "a", it takes last
one
 System.out.println(m3);
 }
} Output:
179
replace():
 replace() is a method ,it is used to replace the index character or word Example
Program:
public class StringBasic {
 public static void main(String[] args) {
 String s1 = "Hello world";
 String m = s1.replace("world", "java"); // to replace world to java
 System.out.println(m);
 }
} Output:
Hello java
Example Program:
public class StringBasic { public static
void main(String[] args) {
 String s1 = "This is manual Testing";
 String m = s1.replace("manual", "Automation"); // to replace manual to
Automation
 System.out.println(m);
 Page
 30
 }
}
Output:
Output:
endsWith():
ASCII value:
 Page
 31
Output:
Output: 77
  It is a method, it is used to compare the character based on ASCII value Example Program:
public class Dummy {
public static void main(String[] args) {
 String s="A";
int i = s.compareTo("A");
 System.out.println(i);
 }
}
Output:
Program:
public class Dummy {
 public static void main(String[] args) {
 String s="A";
 int i = s.compareTo("B");
 System.out.println(i);
 }}
 Page
 32
Output:
1
Here, 65-66=1
 If we use many character, it will compare only first differing character Example
Program:
public class Dummy {
 public static void main(String[] args) {
 String s="ABCD";
int i = s.compareTo("ABFK ");
 System.out.println(i);
 }
 }
Output:
3 // 6770=3
 If it is different length and same accuration, the output will be based on length Example
Program:
public class Dummy {
 public static void main(String[] args) {
 String s="ABCD";
int i = s.compareTo("AB");
 System.out.println(i);
 }
} Output:
42=2
 If different length and different accuration , it will compare the first differing character Example
Program:
public class Dummy { public static void
main(String[] args) {
 String s="ABCD";
int i = s.compareTo("ACLK");
 System.out.println(i);
 }
}
 Page
 33
Output:
Here, 6667=1, BC=1 Literal
String:
  It’s stored inside the heap memory (string pool or string constant).
  It will share the memory if same value (duplicate value) Non-literal string:
31168322
17225372
string:
Example Program:
public class StringBasic {
 public static void main(String[] args) {
 String s1 = "vengat";
 String s2 = "prabu"; // mutable string
 System.out.println("Immutable string");
 System.out.println(System.identityHashCode(s1));
 System.out.println(System.identityHashCode(s2));
 Page
 34
 String r = s1.concat(s2);
 System.out.println(r);
 System.out.println(System.identityHashCode(r));
 StringBuffer x1=new StringBuffer("vengat");
 StringBuffer x2=new StringBuffer("prabu");// mutable string
 System.out.println("mutable string");
 System.out.println(System.identityHashCode(x1));
 System.out.println(System.identityHashCode(x2));
 x1.append(x2);
 System.out.println(x1);
 System.out.println(System.identityHashCode(x1));
 }
}
Output:
Immutable string
31168322 17225372
vengatprabu
COLLECTIONS:
Why we go for collections:
 Page
 35
It has 3 types,
 1. List
 2. Set
 3. Map
1. List :( Interface)
  ArrayList(class)
  LinkedArrayList(c)
  vector(c)
2.Set:(Interface)
  Hashset(c)
  Linked hashset(c)
  Treeset(c)
3.Map:(Interface)
  Hashmap(c)
  Linked hashmap(c)
  Treemap(c)
  Hashtable(c)
  concurrent hashmap(C)
List:
ArrayList:
Syntax:
List ex=new ArrayList();
Here,
Listinterface exobject
name
Program:
public class ArList {
 public static void main(String[] args) {
 List ex=new ArrayList();
ex.add(10);
 ex.add(10000000000000000l);
 ex.add(10.12f);
ex.add("Hai"); ex.add("A");
 ex.add(true);
 System.out.println(ex);
 } }
Output:
 Page
 36
[10, 10000000000000000, 10.12, Hai, A, true]
Program:
public class ArList { public static void
main(String[] args) { List<Integer> ex=new
ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(40);
ex.add(50);
 System.out.println(ex);
 }
}
Output:
[10, 20, 30, 40, 40, 50]
Program:
public class ArList {
 public static void main(String[] args) {
List<Integer> ex=new ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(40); ex.add(50);
int i = ex.size();
System.out.println(i);
 }} Output:
6 get():
Program:
 Page
 37
public class ArList { public static void
main(String[] args) { List<Integer> ex=new
ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(40);
ex.add(50);
 int x = ex.get(3);
 System.out.println(x);
 }
}
Output:
40
loop:
public class ArList { public static void
main(String[] args) { List<Integer> ex=new
ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(40);
ex.add(50);
 for(int i=0;i<ex.size();i++){
 System.out.println(ex.get(i));
 }
 }
}
Output:
10 20
30
40
40
50
 Page
 38
public class ArList { public static void
main(String[] args) { List<Integer> ex=new
ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(40);
ex.add(50);
 for(Integer k:ex){
 System.out.println(k);
 }
 }
}
Output:
10
20
30
40
40
50
Remove():
Output:
 Page
 39
  It is used to add the value based on the index Example
Program:
public class ArList {
 public static void main(String[] args) {
List<Integer> ex = new ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(40);
ex.add(50); ex.add(2,100);
 System.out.println(ex);
 }
}
Output:
 In this o/p , if we insert one value based on index, after all the index value move to backward
set();
 set is a method, it is used to replace the value but index and value order will not change Example
Program:
public class ArList { public static void
 main(String[] args) {
 List<Integer> ex = new ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30); ex.add(40);
 ex.add(40);
ex.add(50); ex.set(2,100);
 System.out.println(ex);
 }
}
Output:
Program:
public class ArList { public static void
main(String[] args) { List<Integer> ex = new
ArrayList<Integer>();
 Page
 40
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(40);
ex.add(50);
 boolean x = ex.contains(30);
 System.out.println(x);
boolean y = ex.contains(100);
 System.out.println(y);
 }
}
Output:
true false
clear():
Program:
public class ArList { public static void
main(String[] args) {
 List<Integer> ex = new
 ArrayList<Integer>(); ex.add(10); ex.add(20);
 ex.add(30);
 ex.add(40);
 ex.add(40);
 ex.add(50);
 System.out.println(ex);// before clearing
 ex.clear();
 System.out.println(ex);// after clearing
 }
}
Output:
[]
indexof():
Program:
public class ArList { public static void
main(String[] args) { List<Integer> ex = new
ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
 Page
 41
ex.add(40); ex.add(40);
ex.add(50);
 int x = ex.indexOf(30);
 System.out.println(x);
 }
}
Output:
Lastindexof():
Program:
public class ArList { public static void
main(String[] args) { List<Integer> ex = new
ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(40);
 ex.add(50);
 int x = ex.lastIndexOf(40); System.out.println(x);
 }
}
Output:
addAll():
 addAll() is a method, it is used to copy from one list to another list Example
Program:
public class ArList {
 public static void main(String[] args) {
List<Integer> ex = new ArrayList<Integer>();
List<Integer> ex1 = new ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
 Page
 42
ex.add(40); ex.add(40);
ex.add(50);
 System.out.println(ex);
 System.out.println(ex1);// before addAll
ex1.addAll(ex);
 System.out.println(ex);
 System.out.println(ex1);// After addAll
 }
}
Output:
[]
removeAll():
  removeAll() is a method , it is used to compare the both list and remove all the list1 values in list
2 (i.e) list2=list2-list1
Example Program:
public class ArList {
 public static void main(String[] args) {
List<Integer> ex = new ArrayList<Integer>();
List<Integer> ex1 = new ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(50);
ex1.addAll(ex);
ex.add(100);
ex.add(200);
ex.add(300);
ex1.add(1000);
ex1.add(50);
ex1.add(2000);
ex1.add(3000);
 System.out.println(ex);
System.out.println(ex1); ex1.removeAll(ex);
 System.out.println(ex1);
 }
}
Output:
 Page
 43
[10, 20, 30, 40, 50, 1000, 50, 2000, 3000] [1000,
2000, 3000]
  If we go for removeAll method, here ex1.removeAll(ex), ex1 compare to ex and remove all ex
 values in the ex1.
retainAll():
 retainAll() is a method, it is used to compare both list and print the common values Example
 Program:
public class ArList {
 public static void main(String[] args) {
List<Integer> ex = new ArrayList<Integer>();
List<Integer> ex1 = new ArrayList<Integer>();
ex.add(10); ex.add(20); ex.add(30);
ex.add(40); ex.add(50); ex1.addAll(ex);
 ex.add(100);
 ex.add(200);
ex.add(300);
ex1.add(1000);
ex1.add(2000);
ex1.add(3000);
 System.out.println(ex);
System.out.println(ex1); ex1.retainAll(ex);
 System.out.println(ex1);
 }
}
Output:
LinkedList: systax:
Program:
public class ArList { public static void
main(String[] args) { List<Integer> ex = new
LinkedList<Integer>();
 Page
 44
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(50);
 System.out.println(ex);
 }
} Output:
Vector: syntax:
Example Program:
public class ArList {
 public static void main(String[] args) { List<Integer>
ex = new Vector<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(50);
 System.out.println(ex);
 }
}
Output:
  In ArrayList deletion and insertion is a worst one because if we delete/insert one index value
after all the index move to forward/backward.  It makes performance issue. ArrayList: Best case
  Searching/retrieving is a worst
  For ex, if we have 100 nodes, we have to print 90th node value, it will pass to all the previous
nodes and comes to first and then it will print.
  It’s makes performance issue Difference between ArrayList and Vector:
ArrayList:
 Page
 45
  Asynchronize
  It is not a thread safe Vector:
  Synchronize
  Thread safe
Here,
If one ticket is having,10 people is booking at a same time, what happen , the one person only booked the
ticket. because its a synchronize process. it allows one by one.
import java.util.ArrayList;
import java.util.List;
 Page
 46
public class Employee extends New {
Class 2:
 Page
 47
 public void setName(String name) {
 this.name = name;
 }
 public String getEmail() {
 return email;
 }
 public void setEmail(String email) {
 this.email = email;
 }
}
Output:
12 vengat
vengat123@gmail.com
13 mohan
mohan123@gmail.co
m
14
vel
vel123@gmail.com
List:
 Page
 48
 }
} Output:
[50, 20, 40, 10, 30] // random order and ignore duplicate value
It will allows one Null value and won't allow duplicate NULL LinkedHashset:
Insertion order
Example Program:
public class ArList {
 public static void main(String[] args) {
Set<Integer> ex = new LinkedHashSet<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(50);
ex.add(50);
 System.out.println(ex);
 }
} Output:
Program:
public class ArList { public static void
main(String[] args) { Set<String> ex =
new TreeSet<String>();
 ex.add("Ramesh");
ex.add("babu"); ex.add("Vasu");
 ex.add("10000");
System.out.println(ex);
 }
}
 Page
 49
Output:
(i.e)
  1ASCII value is 49
  RASCII value is 82
  VASCII value is 86
  bASCII value is 98
  remove is a method , it is used to remove particular value public class ArList { public
static void main(String[] args) { Set<Integer> ex = new TreeSet<Integer>();
 ex.add(10);
 ex.add(20);
 ex.add(30);
 ex.add(40);
 ex.add(50);
 ex.add(50);
 ex.remove(40);
 System.out.println(ex);
 }
 }
Output:
  Normal for loop is not work here because it is not index based, it is value based Enhanced for
 loop:
 Page
 50
public class ArList { public static void
main(String[] args) { Set<Integer> ex = new
TreeSet<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
 ex.add(40);
ex.add(50); ex.add(50);
 for(int i:ex){
 System.out.println(i);
}
}
}
Output:
10
20
30 40
50
 All wrapper class default value is Null as well as all class default value is Null Null:
List:
LinkedHashsetinsertion order
  It is value based
  It ignores duplicate value we can copy the values from List to set as well as set to list Example
Program:
public class ArList { public static void
main(String[] args) { List<Integer> ex=new
ArrayList(); Set<Integer> ex1 = new
TreeSet<Integer>();
 Page
 51
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40); ex.add(50);
ex.add(50); ex.add(10);
ex1.addAll(ex);
 System.out.println(ex);
 System.out.println(ex1);
 }}
Output:
Program:
public class ArList { public static void
main(String[] args) {
 List<Integer> ex = new ArrayList();
Set<Integer> ex1 = new TreeSet<Integer>();
ex.add(10); ex.add(20); ex.add(30);
ex.add(40); ex.add(50); ex.add(50);
ex.add(10); ex1.addAll(ex);
 System.out.println(ex);
System.out.println(ex1); int i =
ex.size() ex1.size();
 System.out.println(i);
 }
}
 Page
 52
[10, 20, 30, 40, 50, 50, 10]
Map:
Output:
TreeMap:
  Random order
  Both key and values are ignore the Null
 Page
 53
Output:
Map<Integer, String> ex = new Hashtable<Integer, String>() concurrent
hashmap:
  Random order
  Both key and values are ignore the Null
HashMap:
get():
Program:
public class ArList {
 public static void main(String[] args) {
 Map<Integer, String> ex = new HashMap<Integer, String>();
 ex.put(10, "Java"); ex.put(20, "Java");
ex.put(30, "sql"); ex.put(40, ".net");
ex.put(50, "sales"); ex.put(50, "fire");
Set<Integer> s = ex.keySet();
 System.out.println(s);
 }
}
 Page
 54
Output: [50, 20,
Value():
Program:
public class ArList {
 public static void main(String[] args) {
 Map<Integer, String> ex = new HashMap<Integer, String>();
 ex.put(10, "Java"); ex.put(20, "Java");
ex.put(30, "sql"); ex.put(40, ".net");
ex.put(50, "sales"); ex.put(50, "fire");
 Collection<String> s = ex.values();
 System.out.println(s);
 }
}
Output:
entryset():
Program:
public class ArList {
 public static void main(String[] args) {
 Map<Integer, String> ex = new HashMap<Integer, String>();
 ex.put(10, "Java"); ex.put(20, "Java");
ex.put(30, "sql"); ex.put(40, ".net");
ex.put(50, "sales");
 ex.put(50, "fire");
 Set<Entry<Integer, String>> s = ex.entrySet(); for(Entry<Integer,
String> x:s){
 System.out.println(x);
 }
 }
}
Output:
50=fire
20=Java
40=.net
 Page
 55
Output:
10=Java 30=sql
Program:
public class ArList {
 public static void main(String[] args) {
 Map<Integer, String> ex = new HashMap<Integer, String>();
 ex.put(10, "Java"); ex.put(20, "Java");
ex.put(30, "sql"); ex.put(40, ".net");
ex.put(50, "sales"); ex.put(50, "fire");
 Set<Entry<Integer, String>> s = ex.entrySet(); for(Entry<Integer,
String> x:s){
 System.out.println(x.getKey());
 System.out.println(x.getValue());
 }
 }
}
50
fire
20
Java
40
.net
10
Java
30
Sql
EXCEPTION:
  Exception is like a error, the program will terminated that line itself Example
Program:
public class Exception { public static void
main(String[] args) {
 System.out.println("Start");
 System.out.println("1");
 System.out.println("2");
 System.out.println("3");
 System.out.println(10/0);
 Page
 56
 System.out.println("4");
 System.out.println("5");
 System.out.println("End");
 }
}
Output:
Start
at org.exception.Exception.main(Exception.java:9)
  This is exception, if we getting error in run time , the program will be terminated from that
line  Here, java:9 is 9th line only we getting exception Throwable:
Unchecked exception:
1. ArithmaticException
2. NullPointException
3. InputMismatchException
4. ArrayIndexOutOfBoundExcepion
5. StringIndexOutOfBoundExcepion
6. IndexOutOfBoundExcepion
1. IOException
2. SQLException
3. FileNotFoundException
 Page
 57
Output:
4. ClassNotFoundException
1. ArithmaticException:
 If we are trying to give any number divided by zero, we get Arithmatic exception.
Example Program:
public class Exception { public static void
main(String[] args) {
 System.out.println("Start");
 Page
 58
 System.out.println("1");
 System.out.println("2");
 System.out.println("3");
 System.out.println(10/0);
 System.out.println("4");
 System.out.println("5");
 System.out.println("End");
 }
}
Output:
Start
at org.exception.Exception.main(Exception.java:9)
2. NullPointException:
  If we give Null in the string, it will throw the Null point exception. Because default value of
 string is Null.
Example Program:
public class Exception {
 public static void main(String[] args) {
 String s= null;
 System.out.println(s.length());
 }
}
Output:
at org.exception.Exception.main(Exception.java:6)
3.InputMismatchException:
  If we getting input from the user, the user need to give integer input but the user trying to input
 string value , at this this we get input mismatch exception
 Page 59
Example Program:
public class Exception { public static void
main(String[] args) {
 Scanner sc=new Scanner(System.in);
System.out.println("PLs enter value");
 int i=sc.nextInt();
System.out.println(i);
 }
}
Output: PLs
enter value
hai
java.util.InputMismatchException at
java.util.Scanner.throwFor(Unknown Source) at
java.util.Scanner.next(Unknown Source) at
java.util.Scanner.nextInt(Unknown Source) at
java.util.Scanner.nextInt(Unknown Source) at
org.exception.Exception.main(Exception.java:9)
4. ArrayIndexOutOfBoundExcepion:
  In particular array, the index value is not available it will throw Array index of
 bound exception.
Example Program:
public class Exception {
 public static void main(String[] args) {
 int num[]=new int[4];
System.out.println(num[5]);
 }
Output:
 Page 60
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at org.exception.Exception.main(Exception.java:8)
5. StringIndexOutOfBoundExcepion:
  In particular String, the index value is not available it will throw String index Out
 of bound exception. Example Program:
public class Exception {
 public static void main(String[] args) {
 String s="Java";
char c = s.charAt(10);
 System.out.println(c);
 }
}
Output:
10 at java.lang.String.charAt(Unknown Source) at
org.exception.Exception.main(Exception.java:8)
6. IndexOutOfBoundExcepion:
 In a list, the index value is not available it will throw index out of bound exception.
Example Program:
public class Exception {
 public static void main(String[] args) {
List<Integer> ex = new ArrayList<Integer>();
 ex.add(10);
ex.add(20); ex.add(30);
ex.add(40);
 System.out.println(ex.get(3));
 System.out.println(ex.get(10));
 }
}
Output:
40
4 at java.util.ArrayList.rangeCheck(Unknown Source) at
 Page 61
java.util.ArrayList.get(Unknown Source) at
org.exception.Exception.main(Exception.java:16)
7. NumberFormatException:
  if we give numbers in the string, we can convert the data type into integer. but if we
 give num and char combination in the string, we can't convert to integer.
  if we trying to convert, it will throw number format exception Example Program:
public class Exception {
 public static void main(String[] args) {
 String s="1234";
 System.out.println(s+5);// string
+5 int i = Integer.parseInt(s);
System.out.println(i+5);// Integer +5
String s1="123Abc45"; int j =
Integer.parseInt(s1);
 System.out.println(j+5);
 }
}
Output:
12345
1239
1. Try
2. Catch
3. Finally
4. Throw
5. Throws
Errors:
 Page 62
1. Network error
2. JVM crack
3. out of memory
 If we get exception, try will throw the exception and catch will catch the exception Example
Program:
public class Exception { public static void
main(String[] args) {
 System.out.println("start");
 System.out.println("1");
 System.out.println("2");
 System.out.println("3");
 try {
 System.out.println(10/0);}
catch(ArithmeticException e){
System.out.println("dont/by zero");
 }
 System.out.println("4");
 System.out.println("5");
 System.out.println("end");
 }
}
Output:
start
23
dont/by
zero
 Here we can enter the same exception or super class of the exception
 Page 63
(i.e)
System.out.println(10/0);}
catch(Throwable e){
System.out.println("dont/by zero");
instead of
try {
System.out.println(10/0);}
catch(ArithmeticException e){
System.out.println("dont/by zero");
Finally:
 Page 64
Outpu
t:
start 1
23
dont/by
zero final
4 5 end
Example program:
public class Exception { public static void
main(String[] args) {
 System.out.println("start");
 System.out.println("1");
 System.out.println("2");
 System.out.println("3");
 try {
 System.out.println(10/0);}
catch(NullPointerException e){
System.out.println("dont/by zero");
 }finally{
 System.out.println("final");
 }
 System.out.println("4");
 System.out.println("5");
 System.out.println("end");
 }
}
Output:
start
23
fin
al
Ex
ce
pti
 Page 65
on
in
thr
ea
"m
ain
"
jav
a.l
an
g.
Ar
ith
me
tic
Ex
ce
pti
on
:/
by
zer
at
or
g.e
xc
ept
 Page 66
io
n.
Ex
ce
pti
on
.m
ain
(E
xc
ept
io
n.j
av
a:1
1)
 Page 67
 System.out.println("end");
 }
}
Output:
start
23
dont/by
zero final
4 5 end
  In a try block, one catch we can use same excepion and another catch we use throwable
 exception
  At this time, it will through the first one if it is match, will print. if it is not correct will throw
 the second
  throwable is the super class of all exception
  In more than one catch block, we can use like sub class and super class combination. But we
 can't use reverse
super classThrowable/Exception
 if we give Super class and sub class combination, it will give compilation error
Example Program:
public class Exception { public static void
main(String[] args) {
 System.out.println("start");
 System.out.println("1");
 System.out.println("2");
 System.out.println("3");
 try {
 System.out.println(10/0);}
catch(NullPointerException e){
System.out.println("null point");
 }
 catch(Throwable e) {
 System.out.println("dont/by zero");
 }
 finally{
 System.out.println("final");
 }
 Page 68
 System.out.println("4");
 System.out.println("5");
 System.out.println("end");
 }
}
Outpu
t: start
23
dont/by
zero final
end
Example Program:
try {
System.out.println(10/0);}
catch(Throwable e) {
System.out.println("dont/by zero");
catch(NullPointerException e){
System.out.println("null point");
finally{
System.out.println("final");
  If we give like above, will get compile time exception/error because we can't reverse
  In one try block, we can write only one finally block Inner try:
  If we use inner try, it will print inner catch, inner finally and outer finally.
  But one try block handle one exception only, even if we use inner try also
 Page 69
  If main try have no exception, it will through inner try. in that inner try if catch exception is
wrong, it will goes and print outer finally Example Program:
public class Exception { public static void
main(String[] args) {
 System.out.println("start");
 System.out.println("1");
 System.out.println("2");
 System.out.println("3");
 try {
 System.out.println(10/0);
 try {
 String s=null;
 System.out.println(s.charAt(0));
 }catch(NullPointerException e){
 System.out.println("inner catch");
 }finally{
 System.out.println("inner finally");
 }
 }
 catch(ArithmeticException e) { System.out.println("dont/by
zero");
 }
 finally{
 System.out.println("outer finaly");
 }
 System.out.println("4");
 System.out.println("5");
 System.out.println("end");
 }
}
Output:
start
23
dont/by
zero outer
finaly
 Page 70
n
Example Program:
public class Exception { public static void
main(String[] args) {
 System.out.println("start");
 System.out.println("1");
 System.out.println("2");
 System.out.println("3");
try {
 System.out.println(10/2);
 try {
 String s=null;
 System.out.println(s.charAt(0));
 }catch(NullPointerException e){
 System.out.println("inner catch");
 }finally{
 System.out.println("inner finally");
 }
 }
 catch(ArithmeticException e) { System.out.println("dont/by
zero");
 }
 finally{
 System.out.println("outer finaly");
 }
 System.out.println("4");
 System.out.println("5");
 System.out.println("end");
 }
}
Output:
start
1
2
3
4
Throw:
 Page 71
  Throws is a keyword, it is used to declare the exception(in method level)
  At a time we can declare more than one exception Example Program:
 public class Exception {
 public static void main(String[] args) throws InterruptedException,
 ArithmeticException,IOException{
 info();
 }
 private static void info() throws IOException
 { System.out.println("hello");
 throw new IOException();
 }
  If we try to throws the compile time exception in any method, we must handle it in
 compile time Example Program:
public class Exception {
 public static void main(String[] args) throws InterruptedException,
ArithmeticException,IOException{
 info();
 }
 private static void info() throws IOException {
System.out.println("hello");
 throw new IOException();
 }
Constructor:
  Class name and constructor name must be same.
  It doesn’t have any return type.
  We don’t want to call constructor which is creating object itself.  It will
 automatically invoke the default constructor.
  It will support in method overloading but won’t support in method
 overriding
Example :
public class Const1 {
 public Const1() {
 System.out.println("i am in constructor");
 }
 public Const1(int a) {
 System.out.println("1 argument int");
 }
 Page 72
 System.out.println(i);
 }
c.Const1(10);
 }
}
Here,
public Const1() Non- Argument based constructor
public Const1(int a)  Argument based constructor
  In argument base constructor we have to pass the argument in object
 Const1 c1=new Const1(10);
  In non-argument base constructor we don’t want to pass any argument
 Const1 c=new Const1();
Output:
i am in constructor
1 argument int
10
This:
  It is a keyword.
  If we use ‘this’ argument , we can pass without object
  This argument we must use only in first statement Example 1:
}
public Const1(int a){
 Page 73
 System.out.println("1 argument int");
}
 }
}
sOutput:
1 argument int
i am in constructor
EXAMPLE 2:
public class sample {
public sample(){
 this(10);
 System.out.println("i am in constructor");
}
public sample(int i) {
 this(23.23f);
 System.out.println("am integer constructor");
}
public sample(float f) {
 System.out.println("am float constructor");
}
Output:
am float constructor
am integer
constructor i am in
constructor
 Page 74
 If we trying to declare any variable without value in class level. It will
 print the default value
 public class sample {
 int id;
 Inside the method, we must initialize the local variable otherwise we get
 compile time error public class sample { int id=10;
 private void num() {
 int id=100;
 System.out.println(id);
 }
 Output: 100
 If same variable name in local level and class level, it will give first
 preference is local level
This():
Class level:
 It will refer the class level variable value Example:
public class sample {
 int id=100; private void
num() {
 System.out.println(id);
 }
 public static void main(String[] args) {
 sample s=new sample();
 s.num();
 }}
Output:
 Page 75
 100
Method level access of this();
Super :
 Page 76
  It will refer the parent class level variable value
 Class 1: Class 2:
 public class sample extends Const1 {
 Output:
 30
Final:
  It’s a keyword.
  If we use final before the variable, we can’t overwrite.  If we trying to
 overwrite it show compile time error.
  As well as if we use final before the method/class, we can’t extend.
  We can use final in three ways,
  Variable level
  Method level
  Class level Variable level using final:
 Page 77
  We can overwrite the value of variable on variable declaration.
  If we final, the value of variable can’t be overwrite.
Example:
Without using final: With using final
 Page 78
Class 1:
 Output:
 output:
 20  We get compile time error.
  if we use final , we can’t overwrite
Method level using final():
Class 2:
public class Const1 extends sample { public void example(){ // we get compile
time error here, because if we use final in method level(parent class), we can't use again
 }
}
 Page 79
 public final class sample
 {}
JAVA INTERVIEW QUESTIONS:
  CLASS:
 • Class is nothing but collection of methods or collection of objects.
  METHOD:
 • A set of action to be performed  OBJECT:
 • Run time memory allocation
 • Using object we can call the any methods
  We can access one class property into another class using 'extend' keyword is called
 inheritance
  Reusable purpose
  It has 5 types
 1. Single Inheritance
 2. Multilevel Inheritance
 3. Multiple Inheritance
 4. Hybrid Inheritance
 5. Hierarchical Inheritance
 Page 80
1. Single Inheritance:
  One parent class is directly support into one child class using extend keyword
2. Multilevel Inheritance:
  More than one parent class support into one child class using extends keyword
3. Multiple Inheritance:
  More than one parent class parallely support into one child class but it won't support
 in java because
 • Priority problem
 • Compilation error/syntax error
 (i.e.) if both parent class having same method name it gets priority problem so it
 doesn't work in java
 During the compilation the java program converts into byte code
  Using byte code we can run the application to any platform such as windows, mac,
 Linux.Etc.
 2. Open source:
  A program in which source code is available to the general public for use and/or
 modification from its original design at free of cost is called open source
 3. Multithreading:
  Java supports multithreading
  It enables a program to perform several task simultaneously 4. More secure:
 Page 81
  It provides the virtual firewall between the application and the computer
5. Portable:
 While:
 Do. While:
 Break:
 Continue:
 Polymany
 Morphismforms
 Page 82
  Taking more than one forms is called polymorphism
  In a same class method name is same and the argument is different is called method
 overloading
  data types
  data types count
  data type order
  In a different class , the method name should be same and argument name should be
 same is called overriding
 It has 2 types,
Abstract class:
 It is partially abstraction
 Page 83
  It support both abstract method and non-abstract method
  Its using "extends" keyword
  Here "public abstract" have to mention
  We can use whatever access specifier we want
Interface:
  It is fully abstraction
  It support only abstract method
  It’s using "implement" keyword
  "Public Abstract" is default. no need to mention
  Here only use public( access specifier)
 Object
 java.lang
Literal String:
 Page 84
Non literal string:
Interface:
  It will support only abstract method, won't support non abstract method
ABSTRACTION:
 It has 2 types,
 Page 85
 It will support abstract method and non-abstract method.
 • We can’t create object for abstract class because in the method signature we
 didn't mention any business logic. so
2. Fully abstraction(interface)
 It will support only abstract method, won't support non abstract method
 Long-8
 Short-2
 Int-4
ACCESS SPECIFIER:
 1. Public
 2. Protected
 3. Default
 4. Private
1. Public:
  It is global level access( same package + different package)
2. Private:
  It is a class level access
3. Default :
  Package level access
 Page 86
  Without access specifier within the package we can access EX,
 4. Protected:
  Inside package + outside Package( Extends)
  we can access inside package and outside package using extend keyword
POLYMORPHISM:
  Poly-many
  Morphism-forms
  Taking more than one forms is called polymorphism.
  One task is completed by many ways
 It has 2 types,
1. Method overloading:
  In a same class method name is same and the argument is different is called
 method overloading
  Data types
  Data types count
  Data type order
2. Method overriding:
 Page 87
  Collection of similar data
  The values are stored based on index
  The index will start from 0 to n-1
HashMap:
Hashtable:
29. What is the difference between linked list and array list?
 Page 88
 30. Can we able to write any logic in interface?
Immutable string:
  We can store more duplicate value in same memory
  We can't change the value in memory
  In concord nation, we have to create new memory
Mutable string:
  We can't store duplicate value in same memory
  We can change the value in memory
  In concord nation, its takes same memory
Thread safe:
Non-thread safe:
34. What are all coding standards available in java? Where we use it?
Coding standards:
 a. Pascal notation
 b. Camel notation
 Page 89
  Pascal notation: Each word of first letter should be in capital
  Camel notation : First word should be small after every word of the first letter should be
 capital
  Pascal notation:
 1. Project name
 2. Class name
  Camel notation :
 1. Method name
 2. Variable name
  If we give Null in the string, it will throw the Null point exception. Because default value of
 string is Null.
List:
Set:
 It is value based
 Page 90
ArrayList:
  Asynchronies
  It is not a thread safe
Vector:
  Synchronize
  Thread safe
Here,
  It has 5 types
 • Hashmap(c)
 • Linked hashmap(c)
 • Treemap(c)
 • Hashtable(c)
 • Concurrent hashmap(C)
 Page 91
 Throw:
Hashset:
Linked hashset:
Treeset:
 Throwable
46. What is the difference between retain all and remove all?
 Page 92
removeAll():
  removeAll() is a method , it is used to compare the both list and remove all the list1
 values in list 2 (i.e)
retainAll():
 retainAll() is a method, it is used to compare both list and print the common values
Advantage of array:
49. What is the difference between normal class and abstract class
 Abstract class:
  It will support abstract method and non-abstract method
  We won’t create object for abstract class
  We won’t write any business logic in abstract method
 Class:
  It support only in non-abstract method
  We can create object for class
Page 93