Skip to content

Commit 70d44a1

Browse files
Create assigning_null_value_to_object2.java
1 parent 8cce947 commit 70d44a1

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class Multiple_objects
2+
{
3+
void display()
4+
{
5+
System.out.println("hi i'm in display function");
6+
7+
}
8+
void show()
9+
{
10+
System.out.println("hi i'm in show function");
11+
}
12+
13+
}
14+
15+
public class Main
16+
{
17+
public static void main(String[] args)
18+
{
19+
Multiple_objects ob1=new Multiple_objects();
20+
Multiple_objects ob2=ob1;
21+
ob2=null;
22+
ob1.display();
23+
ob2.show();
24+
25+
}
26+
}
27+
/*
28+
29+
hi i'm in display function
30+
Exception in thread "main" java.lang.NullPointerException
31+
*/

0 commit comments

Comments
 (0)