Quiz Space

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

Question 1

+4 marksOne correct option

Consider the Java code given below.

java
1 class ClassOne{
2 public void methodOne(){
3 // ...
4 }
5 public void methodTwo(){
6 // ...
7 methodOne();
8 // ...
9 }
10 }
11 class ClassTwo{
12 public static void methodThree(){
13 // ...
14 ClassOne c = new ClassOne();
15 c.methodTwo();
16 // ...
17 }
18 public static void main(String[] args) {
19 // ...
20 methodThree();
21 }
22 }

During execution of Line 8 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.

Consider the following code.

java
class Equipment implements Cloneable{
String type;
// Constructor
// Accessor method getType()
// Mutator method setType()
public Equipment clone() throws CloneNotSupportedException{
return (Equipment)super.clone();
}
}
class Lab implements Cloneable{
Equipment eqp;
String name;
// Constructor
// Mutator method setName()
public Lab clone() throws CloneNotSupportedException{
Lab lb = (Lab)super.clone();
lb.eqp = lb.eqp.clone();
return lb;
}
public String toString(){
return eqp.getType() + ":" + name;
}
}
public class Test {
public static void main(String[] args) {
Lab lb1 = new Lab(new Equipment("Computer"), "Computer");
try{
Lab lb2 = lb1.clone();
lb2.eqp.setType("Milling Machine");
lb2.setName("Mechanical");
System.out.println(lb1);
System.out.println(lb2);
}
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 Animal{
public void legs(){
System.out.println("Number of legs are not known");
}
public void wings(){
System.out.println("Wings may exist");
}
}
class Dog extends Animal{
public void legs(){
System.out.println("Four legs");
}
}
class Ostrich extends Animal{
public void legs(){
System.out.println("Two legs");
}
public void wings(){
System.out.println("Two wings");
}
}
public class Test{
static void show(Animal[] a){
for(int i = 0; i < a.length; i++){
a[i].legs();
a[i].wings();
}
}
public static void main(String[] args){
Animal[] a = {new Dog(), new Ostrich()}; // LINE 1
show(a);
}
}

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-S1 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-S1: 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-S1 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