What is the following program`s execution result?

class Tack {
    static short s = 17;
    public Tack(short ss) {
        new Tack();
        s *= ss;
    public Tack() { ; }
public class Bridle extends Tack {
    public Bridle(int s) { System.out.println(s + 1); }
    public static void main(String[] args) {
        Bridle b = new Bridle(3);
Constructor parameter s hides static variable s because it is more close to context - thus in constructor of class Bridle, s is holding value 3.

Follow CodeGalaxy

Mobile Beta

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