Java Revision
1. DataTypes ---
Primitive -- Size is aleredy defined in java
Exa - byte,short,int ,long, float, double, boolean,
char
Non-Primitive - USer will define the size
String , Arrays
===========================================
===========================================
2. Operators -
Arithmetic - +,-, *,/,%,++, --
Assignment - =
Comparsison -- >, <, >=, <=,==,!=
logical -- &&(both condition true), ||(atleast One
condition should be true ), ! (reverese the result)
===========================================
===========================================
3. String methods -- length, charAt,toUpprcase, to Lowercase,
concat, equals, contains, substring ,
equals, equalsignorecase, contains, repalce,
replaceAll , trim, split
Programming quetions --
1. String reverse
===========================================
===========================================
4. Typecasting -- converting one data type to another
Widening(automtically) (implicit) -- convert smaller to larger
int a=5;
float f =a;
narrowing (manual) (explicit) --convert larger to smaller
int a=5;
float f=(float)a
===========================================
===========================================
5. Condition blocks --
1) if else -- nested if else
2) switch
===========================================
===========================================
6. Loops --
for loop -
nested for loop ---
for each(Advanced for loop)
while loop --
do while loop
Diffrence between for loop and while loop --
Diffrence betwee while and do while loop --
===========================================
===========================================
7. Arrays -- To store multiple values in a single vraible of same
daattype -.
Limitations -
Size is fixed
Cannot delete or add value
Single Dimential Array
2 D array
Find out Second max and second min number from
array .
Count of words
Seperate 0's and 1's
===========================================
===========================================
8. Methods --
static method
non -static method
method with return type--
paramterized method --
===========================================
===========================================
9.OOPS concepts ---
1) Inheritance -
Defination/purpose -- Code reusability ...
Types -
Real times use in framework
i) single
class A
Class B extends A
ii) multilevel -
Class A
Class B extends A Class C extends B
iii) hirarachical -
Class A
ClassB extends A Class C extends A
iv) multiple --
Class A Class B
Class c extends A, B
This is not possible.. we need to use
interface
v) hybrid -- Mix of any two
Inheritance
2. Polymorphissm -
Def/purpose -- Many forms --
Types --
1) Compile Time polynoprhism(Method Overloading
)-
Same method name with diffrent paramaters --
2) Run time Polymorphsim (Method Oveerdiing )
same method name with same paramters and we
should achive through inheritance ..
Real time use in framework --
3. Abstraction --
Def -- Hide sensetive data and show only essential
information ---
To Achieve the abstraction we have two ways ---
i) Abstract class
ii)interface
1. Abstract class ---
1. Abstract class can contain regular methods and
asbtarct methods
2. Abstract methods can be declare only
inside the abstract class --
3. Abstract methods do not have body ,
need to write in sbuclass
4. We cannot create object of abstract
class , we need to create object of subclass
2. Interface ---
1 .Interface contains by default abstract
method.
2. We cant create object of interface , use
the implements class to create the objects
3. interface methods do not have body ,
write inside the implements class .
4. multiple inheritance is possibe with
interface .
5. class implements the interface
class --> class --extends
interface --> class --> implemnents
interface -> interface --> extends
Abstract class
Interface
1. We can have regular and abstract methods
1. By defaulta all the methods are abstract
2.cannot create object of abstarct class
2. Cannot create object of interface
3. we need to use extends keyowrd
3 We need to implements keyword
4.you can achive partial abstarction here
4. You can achive 100 % abstarction here
4. Encapsulation ---
Def - Wrapping data into a single unit --
//Enapsualtion Def --- Wrapping a data into a single unit --
//Advanatages -- 1.hide the data ---
2. control the class read or write --
//To achieve the encapsulation ---
1. Declare the attributes/variable as private
2. Use public getter and setter method to access and update
the value of private variable.
// getter --access --get
//setter -- update --set
Real time use in framework ----
===========================================
===========================================
10. Modifers -
Access modifiers -
Class -public , default
Method, Variables, Constrcutors- public , private , default ,
protected.
Non-Access modifiers --
Class - final , abstract
Method & Variable -- final, static , abstarct
===========================================
===========================================
11. Exception handeling --
Explain Exception hirarachy -
try , catch , finally, throw and throws--
How to crate custom Exception ?
Throw and throws keyword diffrence?
===========================================
===========================================
12. Collections ---
Hashset, hashmap , arraylist , linkehashset --
1. Diffrence between array and arraylist --
2. diffren between set, map and list --
3. fixed seqncee but dont want duplicates -- linkedhashset --
4. programming quetiosn-
Remove duplicates
Ocuramce of each character using hashamp
first releted , last repeted, first non-repeted and
last non -rpeeted
Print duplicates
5. implementaions --
===========================================
===========================================
13. constrcutor --
used to initlaize the object ---
rules --
1. constructor name should be same as classname
2. dosnt have any return type
3. constrcutr will get call automtically at the time of
object createion
Types
Zero-Argument
Parameterzied
Default
Can we overload the constrcutor -yes
Can we oveeride the cobstrcuor --No
Can we overload the static method -- yes
Can we overide the static method --No
Can we overload main method -- yes
Can we override main method --No
===========================================
===========================================
14. Wrapper classes ---
This will help us to use primitive data type as object --
byte Byte
===========================================
===========================================
15. Final and finally diffrence -
===========================================
===========================================
16. This and super diffrence --
===========================================
===========================================
17. .equal and == diffeence --
===========================================
===========================================
18. String , string buffer and string builder --
===========================================
===========================================
16. String, String buffer and String builder -- done
String
String Buffer String Builder
1)*Storage:- SCP+Heap
Heap Heap
2)*Mutability:- immutable
mutable mutable
3)Performance:- slow
compare to string fast fast compare to String buffer
4)Use:- if your String isn't
changing frequently changing frequently
changing frequently
5)ThreadSafe Not thread safe
synchronized methods not synchronized methods
& thread safe & not thread safe
===========================================
===========================================
17. jdk,jre and jvm --
JDK -- Java developement Kit
JRE -- Java runtime enviornment
JVM --- Java virtual machine --To verify the byte
code ---
===========================================
===========================================
18. user inout programs --