What happens as a result of compiling and running the following code:

public class Bar extends Foo {               // 1
    public static void main(String[] args) { // 2
        System.out.print(sum(1, 2));         // 3
    }
}
class Foo {
    int sum(int x, int y) {
        return x + y;
    }
}

So you can init a main method in an extended class?

2023 Feb 16, 3:10:52 AM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes