0

Can we pass class or class reference variable in method as parameter.

class Animal { } class Monkey extends Animal { } class Test { public void m1(Animal a) { system.out.println("Animal version") } } public static void main(String[] args) { Test t = new Test(); Animal a=new Animal(); t.m1(a); } what will be the output of above code please elaborate .

4th Jul 2018, 7:02 AM
ANURAG RASTOGI
ANURAG RASTOGI - avatar
7 odpowiedzi
+ 2
When ran this code in on Code Playground what were the results. Let this be your first code.
4th Jul 2018, 7:12 AM
ODLNT
ODLNT - avatar
+ 1
Anurag Rastogi Did the results answer your question?
4th Jul 2018, 7:21 AM
ODLNT
ODLNT - avatar
+ 1
Are you saying your code didn't work, or you don't understand the results?
4th Jul 2018, 8:01 AM
ODLNT
ODLNT - avatar
+ 1
Either make your code public or post it in this thread.
4th Jul 2018, 8:06 AM
ODLNT
ODLNT - avatar
0
Animal version is the output
4th Jul 2018, 7:13 AM
ANURAG RASTOGI
ANURAG RASTOGI - avatar
0
nopes ...I didnt get it
4th Jul 2018, 7:56 AM
ANURAG RASTOGI
ANURAG RASTOGI - avatar
0
m talking about the results ..there are more functions calls in main funtion which I hvnt mentioned ..I have posted full code on my profile
4th Jul 2018, 8:03 AM
ANURAG RASTOGI
ANURAG RASTOGI - avatar