Quiz Space

Java End Term: 30 April 2023, Set QPD1-S2 (January 2023 term)

Question 1

+4 marksOne correct option

Consider the Java code given below.

java
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?

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

Question 2

+4 marksOne correct option

Consider the following code.

java
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?

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

Question 3

+4 marksOne correct option

Consider the code given below

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

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

20 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 End Term 30 Apr 2023 Set QPD1-S2 paper

The IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 30 Apr 2023, in the January 2023 term, set QPD1-S2: 23 questions for 100 marks in 180 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 End Term 30 Apr 2023 Set QPD1-S2 at a glance
TermJanuary 2023 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions23
Marks100
Duration180 min
MCQ16
MSQ7
Official paperIIT M DIPLOMA ET1 EXAM QPD1 S2 30 Apr 2023
Negative markingNo negative marking.
Updated

Other sets that day

Same End Term, other subjects

More Java