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

RMS Java Revision

Uploaded by

Richa Singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

RMS Java Revision

Uploaded by

Richa Singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Java Revision

1. Data Types :
Primitive :- Size is already defined in java
1) byte
2) short
3) int
4) long
5) float
6) double
7) Boolean
8) char

Non-Primitive :- User will define the size


1) String
2) Arrays

==================================================================================
==================================================================================
2. Operators :
1) Arithmetic :-
1) +
2) -
3) *
4) /
5) %
6) ++
7) --

2) Assignment :-
1) =

3) Comparison :-
1) >
2) <
3) >=
4) <=
5) ==
6) !=

4) logical :-
 &&(both condition true)
 ||(at least One condition should be true )
 ! (reverse the result)

==================================================================================
==================================================================================
3. String methods :
1) Length

2) charAt

3) toUpprcase

4) toLowercase

5) concat

6) contains

7) substring

8) equals

9) equalsignorecase

10) replace

11) replaceAll

12) trim

13) split

Programming questions :-

1. String reverse

==================================================================================
==================================================================================
4. Typecasting :
converting one data type to another.

1) Widening(automatically) (implicit) :-
convert smaller to larger

2) narrowing (manual) (explicit) :-


convert larger to smaller
==================================================================================
==================================================================================
5. Condition blocks :
1) if else :-

2) nested if else :-

3) switch :-

==================================================================================
==================================================================================
6. Loops :

1) for loop :-

2) nested for loop :-

3) for each(Advanced for loop) :-

4) while loop :-

5) do while loop :-

Difference between for loop and while loop :-

Difference between while and do while loop :-


==================================================================================
==================================================================================
7. Arrays :
To store multiple values in a single variable of same datatype.

Syntax :

Limitations :-
Size is fixed
Cannot delete or add value

Types :-
Single Dimensional Array
2 D array

Programming Questions :-
1) Find out Second max and second min number from array .
2) Count of words
3) Separate 0's and 1's

==================================================================================
==================================================================================
8. Methods :
1) static method
Syntax :

2) non -static method


Syntax :

3) method with return type


Syntax :

4) parametrized method
Syntax :

==================================================================================
==================================================================================
9. OOPS concepts :
1) Inheritance :-
 Definition –
 purpose –
 Types –
1) Single

2) Multilevel

3) Hierarchical

4) Multiple Hybrid

2) Polymorphissm :-
 Definition –
 purpose –
 Types –

1) Compile Time polymorphism(Method Overloading ) -

Same method name with different parameters.

2) Run time Polymorphism (Method Overriding )

same method name with same parameters and we should achieve through inheritance.
3) Abstraction :-
 Definition – Hide sensitive data and show only essential information
 purpose –
 Types – To Achieve the abstraction we have two ways
I) Abstract class
II) interface

I) Abstract class ---

1. Abstract class can contain regular methods and abstract methods

2. Abstract methods can be declare only inside the abstract class --

3. Abstract methods do not have body , need to write in subclass

4. We cannot create object of abstract class , we need to create object of subclass

II) Interface ---

1 .Interface contains by default abstract method.

2. We can’t create object of interface, use the implements class to create objects

3. interface methods do not have body, write inside the implements class .

4. multiple inheritance is possible with interface .

5. class implements the interface

// Class ---> Class ---> extends

// Interface ---> Class ---> implements

// Interface ---> Interface ---> extends

Abstract class Interface

1. We can have regular and abstract methods 1. By default all the methods are abstract ‘
‘ methods

2.cannot create object of abstract class 2. Cannot create object of interface

3. we need to use extends keyword 3 We need to implements keyword

4.you can achieve partial abstraction here 4. You can achieve 100 % abstraction here
4) Encapsulation :-
 Definition – Wrapping data into a single unit
 Advantages –
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

==================================================================================
==================================================================================
10. Modifiers :
I) Access modifiers –
Class - public , default
Method, Variables, Constructors - public , private , default , protected.

II) Non-Access modifiers –


Class - final , abstract
Method & Variable - final, static , abstract

==================================================================================
==================================================================================
11. Exception handling :

Explain Exception hierarchy –

try , catch , finally, throw and throws--

How to create custom Exception ?

Throw and throws keyword difference?

==================================================================================
==================================================================================
12. Collections :

HashSet, HashMap , ArrayList , LinkedHashSet

1. Difference between array and ArrayList

2. Difference between set, map and list

3. fixed sequence but don’t want duplicates -- LinkedHashSet

4. programming questions-

a) Remove duplicates
b) Occurrence of each character using HashMap
c) first related
d) last repeated
e) first non-repeated
f) last non -repeated
g) Print duplicates

5. Implementations –

==================================================================================
==================================================================================

13. Constructor :

Used to initialize the object

rules –

1. constructor name should be same as className

2. don’t have any return type

3. constructer will get call automatically at the time of object creation

Types –

1. Zero-Argument

2. Parameterized

3. Default

Can we overload the constructor -yes

Can we override the constructor --No

Can we overload the static method -- yes

Can we override 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 objects

// We have used inside the collections..

Primitive data-type Wrapper Class


byte Byte
short Short
int Integer
long Long
float Float
double Double
boolean Boolean
char Character
==================================================================================
==================================================================================
15. Final and finally difference :

==================================================================================
==================================================================================

16. This and super difference --

==================================================================================
==================================================================================

17. .equal and == difference --

==================================================================================
==================================================================================

18. String , string buffer and string builder --

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) Thread Safe:- Not thread safe synchronized methods not synchronized methods
& thread safe & not thread safe

==================================================================================
==================================================================================

19. JDK, JRE, JVM :

JDK -- Java development Kit

JRE -- Java runtime environment

JVM --- Java virtual machine --To verify the byte code ---

==================================================================================
==================================================================================

20. user input programs --

You might also like