Programming Concepts using Java, End Term
Consider the Java code given below.
1 class Example{ 2 public void functionOne(){ 3 // ... 4 functionTwo(); 5 // ... 6 } 7 public void functionTwo(){ 8 // ... 9 }10 public static void functionThree(){11 // ...12 Example e = new Example();13 e.functionOne();14 // ...15 }16 public static void main(String[] args) {17 // ...18 functionThree();19 }20 }During execution of Line 14 in the above code, the activation record of which method is at the top of the stack of activation records?
Consider the Java code given below. 1 class Example{ 2 public void functionOne(){ 3 // ... 4 functionTwo(); 5 // ... 6 } 7 public void functionTwo(){ 8 // ... 9 } 10 public static void functionThree(){ 11 // ... 12 Example e = new Example(); 13 e.functionOne(); 14 // ... 15 } 16 public static void main(String[] args) { 17 // ... 18 functionThree(); 19 } 20 } During execution of Line 14 in the above code, the activation record of which method is at the top of the stack of activation records? Consider the following code. class ContactInfo implements Cloneable{ String email; // Constructor // Accessor method getEmail() // Mutator method setEmail() public ContactInfo clone() throws CloneNotSupportedException{ return (ContactInfo)super.clone(); } } class Student implements Cloneable{ String name; ContactInfo ci; // Constructor // Mutator method setName() public Student clone() throws CloneNotSupportedException{ Student s = (Student)super.clone(); s.ci = s.ci.clone(); return s; } public String toString(){ return name + ":" + ci.getEmail(); } } public class Test { public static void main(String[] args) { Student s1 = new Student("Rahul", new ContactInfo("mail")); try{ Student s2 = s1.clone(); s2.ci.setEmail("new mail"); s2.setName("Sreeja"); System.out.println(s1); System.out.println(s2); } catch(Exception e){ System.out.println(e); } } } What will the output be? Consider the code given below class Shape{ public void area(){ System.out.println("Area exists"); } public void sides(){ System.out.println("Sides may exist"); } } class Circle extends Shape{ public void area(){ System.out.println("Circle area"); } } class Rectangle extends Shape{ public void area(){ System.out.println("Rectangle area"); } public void sides(){ System.out.println("Four sides"); } } public class Test{ static void display(Shape[] s){ for(int i = 0; i < s.length; i++){ s[i].area(); s[i].sides(); } } public static void main(String[] args){ Shape[] s = {new Circle(), new Rectangle()}; // LINE 1 display(s); } } Choose the correct option.