Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Java Programming Language Interviews:Advanced JavaCore JavaEclipseFull Stack Developer (Java)HibernateIBM WebSphereInternationalization LocalizationJ2EEJ2MEJ2SEJavaJava ANTJava AppletJava BeansJava ClassesJava EJB ProgrammingJava Game DeveloperJava GUI FrameworkJava JNDIJava JNIJava JSP ProgrammingJava Message Service (JMS)Java Multi-ThreadingJava Networking - Sockets and RMIJava PatternsJava SecurityJava Server FacesJava Servlet ProgrammingJava Software EngineerJava Swing ProgrammingJava TechnicalJava ThreadsJava Transaction APIJava Web ServicesJavaMailJBossJDBCJMSJSFPortal and PortletRMISpring FrameworkSr.Java Web DeveloperStrutsSunOneSwing AWTSWT JFace
Copyright © 2018. All Rights Reserved
Java Software Engineer Interview Question:
Explain me why doesn't the following code generate a NullPointerException even when the instance is null?
Submitted by: MuhammadTest t = null;
t.someMethod();
public static void someMethod() {
...
}
There is no need for an instance while invoking a static member or method, since static members belongs to a class rather than an instance.
A null reference may be used to access a class (static) variable without causing an exception.
Submitted by: Muhammad
t.someMethod();
public static void someMethod() {
...
}
There is no need for an instance while invoking a static member or method, since static members belongs to a class rather than an instance.
A null reference may be used to access a class (static) variable without causing an exception.
Submitted by: Muhammad
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.