Tomorrow Is Another Day
Either travel, either reading, body and soul must be one on the road
Pages
Home
COMP
Tech Links
Wednesday, 23 November 2016
What is the output of following program?
What is the output of following program?
package com.instanceofjava;
public class A{
public static void show(){
System.out.println("Static method called");
}
public static void main(String[] args) {
A obj=null;
obj.show();
}
}
Click for Output
Static method called
Exaplanation:
We can call static methods using reference variable which is pointing to null because static methods are class level so we can either call using class name and reference variable which is pointing to null.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment