Search:     Advanced search
Browse by category:
C/C++   |   Java   |   Oracle/Database   |   SAP   |   ASP .NET   |   Mainframe-DB2   |   Freshers

What is NullPointerException and how to handle it?

Add comment
Views: 419
Votes: 0
Comments: 0
When an object is not initialized, the default value is null. When the following things happen, the NullPointerException is thrown:
--Calling the instance method of a null object.
--Accessing or modifying the field of a null object.
--Taking the length of a null as if it were an array.
--Accessing or modifying the slots of null as if it were an array.
--Throwing null as if it were a Throwable value.
The NullPointerException is a runtime exception. The best practice is to catch such exception even if it is not required by language design.
Others in this Category
document How do I use a scriptlet to initialize a newly instantiated bean?
document Objects are passed by value or by reference?
document What's the difference between a primary key and a unique key?
document Q: What are checked exceptions?
document Explain the directory structure of a web application.
document What is point-to-point messaging?
document Q: What is final?
document If I write System.exit (0); at the end of the try block, will the finally block still execute?
document Why do we need wrapper classes?
document Q: State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.
» More articles



RSS