Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Dhoom3 {
    public static void main(String[] args) {
        Katrina kaif = new Katrina();
        kaif.addObserver(new Amir());
        kaif.addObserver(new Abhishek());
        kaif.notifyObservers();
        kaif.upgrade();
        kaif.deleteObserver(new Amir());
        kaif.notifyObservers();
    }
}
class Katrina extends Observable {
    public Katrina() {
        setChanged();
    }
    void upgrade() {
        setChanged();
    }
}
class Amir implements Observer {
    public void update(Observable arg0, Object arg1) {
        System.out.print("Kat | ");
    }
}
class Abhishek implements Observer {
    public void update(Observable arg0, Object arg1) {
        System.out.print("Kaif <> ");
    }
}


Kaif <> Kat |
Kaif <> Kat | Kaif <> Kat |
Kaif <> Kat | Kaif <>
No output is generated
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Observable

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App