Programming Concepts using Java, Quiz 1
Which among the following statements is/are true about activation records?
Which among the following statements is/are **true** about activation records? Consider the code given below that checks whether two books are the same. Method equals is overridden to compare two Book objects as follows. If two books have the same author name and book name, then they are the same. Based on the given information, answer the question that follows. class Book{ private String bName; // Book name private String aName; // Author name //Constructor to initialize instance variables public String toString() { return bName; } public boolean equals(Object obj) { // CODE BLOCK } } public class Test { public static void main(String[] args) { Book b1 = new Book("ABC", "XYZ"); Book b2 = new Book("ABC", "XYZ"); if(b1.equals(b2)) System.out.println(b1+", "+ b2 +" are same"); else System.out.println(b1+", "+ b2 +" are different"); } } Choose the correct option(s) to fill in place of CODE BLOCK so that the output is: ABC, ABC are same Consider the code given below. class Rectangle{ private int sides; public Rectangle(int s){ sides = s; } public final void area(){ System.out.println("area of rectangle"); } } class Pentagon extends Rectangle { public Pentagon(int n){ super(n); } public final void area(){ // LINE 1 System.out.println("area of pentagon"); } } public class Test{ public static void main(String[] args){ Rectangle r = new Pentagon(4); // LINE 2 r.sides = 5; // LINE 3 r.area(); } } Choose the correct option(s).