0% found this document useful (0 votes)
11 views12 pages

JAVArevision

This document provides a comprehensive overview of Java programming concepts, including data types, operators, string methods, typecasting, condition blocks, loops, arrays, methods, OOP principles, modifiers, exception handling, collections, constructors, wrapper classes, and differences between various Java components. It also includes programming questions and examples related to these topics. Additionally, it explains the roles of JDK, JRE, and JVM in Java development.

Uploaded by

Richa Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views12 pages

JAVArevision

This document provides a comprehensive overview of Java programming concepts, including data types, operators, string methods, typecasting, condition blocks, loops, arrays, methods, OOP principles, modifiers, exception handling, collections, constructors, wrapper classes, and differences between various Java components. It also includes programming questions and examples related to these topics. Additionally, it explains the roles of JDK, JRE, and JVM in Java development.

Uploaded by

Richa Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Java Revision

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

Non-Primi ve :- User will define the size


1) String
2) Arrays

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

2) Assignment :-
1) =

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

4) logical :-
 &&(both condi on true)
 ||(at least One condi on 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 ques ons :-

1. String reverse

==================================================================================
==================================================================================
4. Typecas ng :
conver ng one data type to another.

1) Widening(automa cally) (implicit) :-


convert smaller to larger

2) narrowing (manual) (explicit) :-


convert larger to smaller

==================================================================================
==================================================================================
5. Condi on 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 mul ple values in a single variable of same datatype.

Syntax :

Limita ons :-
Size is fixed
Cannot delete or add value

Types :-
Single Dimensional Array
2 D array

Programming Ques ons :-


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) sta c method
Syntax :

2) non -sta c method


Syntax :

3) method with return type


Syntax :

4) parametrized method
Syntax :

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

2) Mul level

3) Hierarchical

4) Mul ple Hybrid

2) Polymorphissm :-
 Defini on –
 purpose –
 Types –

1) Compile Time polymorphism(Method Overloading ) -

Same method name with different parameters.

2) Run me Polymorphism (Method Overriding )

same method name with same parameters and we should achieve through inheritance.
3) Abstrac on :-
 Defini on – Hide sensi ve data and show only essen al informa on
 purpose –
 Types – To Achieve the abstrac on 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. mul ple 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 par al abstrac on here 4. You can achieve 100 % abstrac on here
4) Encapsula on :-
 Defini on – Wrapping data into a single unit
 Advantages –
1.hide the data
2. control the class read or write

To achieve the encapsula on ---

1. Declare the a ributes/variable as private

2. Use public ge er and se er method to access and update the value of private variable.

// ge er --access --get

//se er -- 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, sta c , abstract

==================================================================================
==================================================================================
11. Excep on handling :

Explain Excep on hierarchy –

try , catch , finally, throw and throws--

How to create custom Excep on ?

Throw and throws keyword difference?

==================================================================================
==================================================================================
12. Collec ons :

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 ques ons-

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. Implementa ons –

==================================================================================
==================================================================================
13. Constructor :

Used to ini alize the object

rules –

1. constructor name should be same as className

2. don’t have any return type

3. constructer will get call automa cally at the me of object crea on

Types –

1. Zero-Argument

2. Parameterized

3. Default

Can we overload the constructor -yes

Can we override the constructor --No

Can we overload the sta c method -- yes

Can we override the sta c method --No

Can we overload main method -- yes

Can we override main method --No

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

14. Wrapper classes :

// This will help us to use primi ve data-type as objects

// We have used inside the collec ons..

Primi ve 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 run me environment

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

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

20. user input programs --

You might also like