GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 909 of 923    Print  
Nullpointer Exception
What is Nullpointer Exception How it will be reduced


  
Total Answers and Comments: 2 Last Update: April 14, 2008     Asked by: vijayramd 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 02, 2008 01:23:34   #1  
shyamgosavi648 Member Since: April 2008   Contribution: 1    

RE: Nullpointer Exception
I can give you example
 if you create string array and you not assing any value for that string object. 
when you want print this array  the JVM give Null pointer Exception              

 
Is this answer useful? Yes | No
April 14, 2008 07:43:33   #2  
abuthahir.d Member Since: January 2008   Contribution: 10    

RE: Nullpointer Exception
There are many reasons to get a Null pointer Exception .

Burn it in ur Brain : NullPointerException can occur only on OBJECTS . not primitives.

the above said answer holds a good example .

Example 2:
 String s = null;
  System.out.println(s.concat("asdad") ); 
will throw NullPointerException . This happens because we are trying to ivoke a methos in a null Object .

 
Is this answer useful? Yes | No

 Related Questions

If a checked exception may be thrown within the body of a method, the method musteither catch the exception or declare it in its throws clause. 
Latest Answer : this rule is actually for handling the exceptions:that is there are two ways by ehich u can handle the exception :1:either you use the try catch statement and enclose the appropriate code in the try catch block,this is called as the catch or the HANDLE ...

The finally clause is used to provide the capability to execute code no matter whether ornot an exception is thrown or caught. 
Latest Answer : In try,catch clauses either try clause(If exception is not happend) or catch clause(If exception occures) is exicuted.If we want to exicute a block of statements doesn't depend on exception then we put those block of statements in finally ...

A catch clause can catch any exception that may be assigned to the Throwable type. Thisincludes the Error and Exception types. 

Yes, an exception can be rethrown. 

The finally clause of the try-catch-finally statement is always executed unless the threadof execution terminates or an exception occurs within the execution of the finally clause. 

An uncaught exception results in the uncaughtException() method of the thread'sThreadGroup being invoked, which eventually results in the termination of the programin which it is thrown. 

What happens if a try-catch-finally statement does not have a catch clause to handlean exception that is thrown within the body of the try statement
The exception propagates up to the next higher level try-catch statement (if any) orresults in the program's termination. 

When an exception is thrown within the body of a try statement, the catch clauses of thetry statement are examined in the order in which they appear. The first catch clause that iscapable of handling the 
Latest Answer : If you are trying to catch the specific exception  ,  write that catch clause prior to the other / general clauses.Otherwise the compilation error "The Exception already been caught" will occur.Try this code:try {// some code}catch(Exception ...

Answered by Scott on 2005-05-12 09:50:36: An Exception can be caught and recovered: ArrayIndexOutOfBoundsException means you tried to access a position of an Array that does not exist - no big deal.  An 
Latest Answer : exception will give user friendly message which is defined in exception handling,whereas error message is standard given by oracle. ...

Latest Answer : Java supports exception handling by its try catch constructs. Java API define exception classes for such conditions. These classes are derived from java.lang.Throwable class. User defined exceptions are those exceptions which an application provider or ...


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

JavaScript Exception Handling – Part II

JavaScript Exception Handling Part II In this JavaScript tutorial you will learn about exception handling viz try… catch finally statement and nested try… catch statements along with syntax and examples mosgoogle center try… catch finally Statement JavaScript has a
 

JavaScript Exception Handling – Part I

JavaScript Exception Handling Part I In this JavaScript tutorial you will learn about Exception Handling Catching errors in JavaScript Using try catch statement and throw in JavaScript along with syntax and examples mosgoogle center It is impossible for a programmer to write a program without erro
 

Using UML with Java

Using UML with Java While Java is not a new language its application for the development of embedded systems is quite new Developers are beginning to take a second look at modeling languages such as UML and many feel it can be a powerful tool in their development arsenal mosgoogle center Introductio
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

Java Technology Trends

Technology Trends Involving Java Java is an object oriented programming language OOP for Web browsers It is organized around data rather than actions and supports polymorphism which allows the same code to be written generically so it can function with different datatypes inheritance which allows on
 

HR Interview - HR Interview Mistakes You Will Want To Avoid

HR Interview Mistakes You Will Want To Avoid The job interview can be a stressful process This is especially true for those who are going after a competitive position Your nonverbal communication combined with the answers you give during the interview will determine if you are hired mosgoogle While
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape