group-icon
Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
263 Members
Join this group to post and comment.
Soubhik Maji
Soubhik Maji
Computer Science
12 Jan 2019

Wrapper classes & Exceptions

1. Wrapper classes are used to convert primitive types into object type and vice-versa . For that all the required methods are present in appropriate classes  . All the wrapper classes are present in java.lang package .

2.Typecasting-converting from one type to another 

3.Implicit -typecasting that is automatically done by the compiler  .

4.Explicit-typecasting that we have to do by ourselves .

5.Widening casting is implicit and safe

6.Narrowing casting is explicit and is unsafe 

7/Exception:-Any bug at run-time  that affects the normal flow of program .How we  handle ......using following keywords 

8.try{} //we put buggy code inside it

Then followed by a catch(){} catch takes argument ..object of the class which the exception belongs ..

9. Finally ...its not requires ...yet if you fail to catch the exception by mentioning wrong exception type as argument to catch ...you ..can do ...anything important that you want to do ...before your program terminates 

10 .Checked exceptions:- Compiler forces you to handle this type of exception .Like jdbc , file io .

11.Unchecked exceptions:-You may or may not handle this exception . Its up to you .

12. Throws keyword:-It is used to explicitly throw a exception  .

13.Cannot write any statements after throw .Unreachable code error .

14.throw new ArithmeticException("__");

//now you should be careful that only classes that extends throwable class  can only be  used for throw 

#Checked Excetions cannot be propagated without throws in function signatures of the function who is  throwing.

15.The caller function has the opportunity to catch the exception .Otherwise it will keeping rolling towards to the jvm.Finally JVM has to handle 

16.you can create your own exception by simply create your own class and extending exception class. All you have to do is take the custom exception message as input parameter to your constructor and call super(s) ; with that string  . 


Lookup code snippets for throws and creating your own exception  by extending Exception .