Give the code. What is the result?
class Hotel {
public int bookings;
public void book() {
bookings++;
}
}
public class SuperHotel extends Hotel {
public void book() {
bookings--;
}
public void book(int size) {
book();
super.book();
bookings += size;
}
public static void main(String args[]) {
SuperHotel hotel = new SuperHotel();
hotel.book(2);
System.out.print(hotel.bookings);
}
}
public int bookings;
public void book() {
bookings++;
}
}
public class SuperHotel extends Hotel {
public void book() {
bookings--;
}
public void book(int size) {
book();
super.book();
bookings += size;
}
public static void main(String args[]) {
SuperHotel hotel = new SuperHotel();
hotel.book(2);
System.out.print(hotel.bookings);
}
}
(Correct Answer) |
No comments:
Post a Comment