Predict the Output
Question 1
Question 2
Question 1
class Base { public void Print() { System.out.println("Base"); } } class Derived extends Base { public void Print() { System.out.println("Derived"); } } class Main{ public static void DoPrint( Base o ) { o.Print(); } public static void main(String[] args) { Base x = new Base(); Base y = new Derived(); Derived z = new Derived(); DoPrint(x); DoPrint(y); DoPrint(z); } }
public class otpur { public static void main(String[] args) { int a=4; cha(a); System.out.println(a); } public static void cha(int a){ System.out.println(++a); } }
Article by Farhan Khwaja Farhan has written 71 articles . If you like This post, you can follow Code 2 Learn on Twitter. Subscribe to Code 2 Learn feed via RSS or EMAIL to receive instant updates. Want to write for Code 2 Learn. Read here for more info |