Quiz Space

Programming Concepts using Java Quiz 1: 16 July 2023 (May 2023 term)

Question 1

+4 marksOne or more correct options

Which among the following statements is/are true about activation records?

Select all that apply.

  1. A

    All the variables on the stack (in any activation record) are in their scope.

  2. B

    Only the variables present in the topmost activation record of the stack are in their lifetime

  3. C

    Every activation record has a control link that points to start of previous record.

  4. D

    Every activation record has a return value link that points to where to store return value.

Question 2

+4 marksOne or more correct options

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.

java
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

Select all that apply.

  1. A
  2. B
  3. C
  4. D

Question 3

+4 marksOne or more correct options

Consider the code given below.

java
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).

Select all that apply.

  1. A
  2. B
  3. C
  4. D

12 more questions in this paper

Sign in with Google — it is free — to see every question with its answer and explanation, practise it in learning mode, or take it as a timed mock test.

More on the Java Quiz 1 16 Jul 2023 paper

The IIT Madras BS Programming Concepts using Java (Java) Quiz 1 paper sat on 16 Jul 2023, in the May 2023 term: 15 questions for 50 marks in 120 minutes. The first 3 questions are below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeatureJava Quiz 1 16 Jul 2023 at a glance
TermMay 2023 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions15
Marks50
Duration120 min
MSQ4
MCQ11
Official paperIIT M FOUNDATION AN2 EXAM QPF2 16 JULY 2023
Negative markingNo negative marking.
Updated

Same Quiz 1, other subjects

More Java