You need to sign in to do that
Don't have an account?

Exceptions?
Hai Friends,
Can you please explain in which situation the following exceptions may raise?
List index out of bounds
String out of bounds
String exception: Satrting position out of bounds
Dereference-the-null object
PLease explain the possible scenarios to get that exceptions
Here are your answers
List index out of bounds : Your are trying to acces any index of list which is not in the list
Ex : List size is 3 then list.get(0) , list.get(1) , list.get(2) , is ok
but list.get(3) will give you this error as max index is 2 so index given by you is out of bound
String out of bounds
String str's length is 5 str ='abcde'
String s = str.substring(2 , 9);
String will go out of bound
String exception: Satrting position out of bounds
Ex : String str's length is 5 str ='abcde'
String s = str.substring(7 , 9);
max characte index is 4 so your startig index is out of bound
but list.get(3) will give you this error as max index is 2 so index given by you is out of bound
Dereference-the-null object
String a = null;
String b = a.toLOwerCase(); // here you are trying to dereference a null object as a is null
All Answers
Here are your answers
List index out of bounds : Your are trying to acces any index of list which is not in the list
Ex : List size is 3 then list.get(0) , list.get(1) , list.get(2) , is ok
but list.get(3) will give you this error as max index is 2 so index given by you is out of bound
String out of bounds
String str's length is 5 str ='abcde'
String s = str.substring(2 , 9);
String will go out of bound
String exception: Satrting position out of bounds
Ex : String str's length is 5 str ='abcde'
String s = str.substring(7 , 9);
max characte index is 4 so your startig index is out of bound
but list.get(3) will give you this error as max index is 2 so index given by you is out of bound
Dereference-the-null object
String a = null;
String b = a.toLOwerCase(); // here you are trying to dereference a null object as a is null
thanks for reply sharma,
i need more possible scenarios.OK i understood from your answer how they are raising.But i want to know kmore.
Thank u sharma