Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

explain me with a code snippet about the generation and
handling of null point exceptions.

Answer Posted / g.arun

class Test
{
public static void main(String[] args)
{
try
{
int a[] = null;
System.out.println(a.length);
}
catch (NullPointerException n)
{
System.out.println(n);
}

}
}
U can try this by changing NullPointerException in catch
block as catch(Exception e){ System.out.println(n);}

and Using throw it is

class Test
{
public static void main(String[] args)
{
int a[] = null;
System.out.println(a.length);
NullPointerException n = new NullPointerException();
throw n;
}
}

Using Throws

class Test
{
public static void main(String[] args) throws
Exception
{
int a[] = null;
System.out.println(a.length);
}
}

That's all friends hope this one helps you

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is lossy conversion in java?

1132


What is an example of declaration?

957


Explain what access modifiers can be used for methods?

1036


What modifiers are allowed for methods in an interface?

1107


How can you avoid serialization in child class if the base class is implementing the serializable interface?

1031


What are the important features of Java 10 release?

960


What is difference between static and final?

1018


What is a void method java?

920


What are the various access specifiers in java?

960


How do you clear a method in java?

968


What types of index data structures can you have in java?

1144


What is protected in java?

956


Is array synchronized in java?

1002


Is an integer an object?

910


What are JVM.JRE, J2EE, JNI?

1061