Upload
roshan-chan
View
216
Download
1
Embed Size (px)
DESCRIPTION
ihkgjkgb
Citation preview
OBJECT CREATION IN JAVA.In the following example we have classes a and b. b extends a. In other words a is the super class and b is the subclass. The following program shows FOUR possibilities of creating objects of the classes a and b and the accessibility of the objects.pacage exercise!public class "xercise #public static void main$%tring&' args( #
a ob)*new a$(!b ob+*new b$(!a ob,*new b$(! -- a ob.*new b$(!/OT 011O2"3
ob).f$(!ob).fa$(!
ob+.f$(!ob+.fa$(!ob+.fb$(!
ob,.f$(!ob,.fa$(!--ob,.fb$(! /OT 011O2"3
4
4run5f In class 0fa In class 0f In class 6fa In class 0fb In class 6f In class 6fa In class 0 $total time5 7 seconds(pacage exercise!public class a #void fa$(#%ystem.out.println$8fa In class 08(!4
void f$(#%ystem.out.println$8f In class 08(!44pacage exercise!public class b extends a#void fb$(#%ystem.out.println$8fb In class 68(!4
void f$(#%ystem.out.println$8f In class 68(!44