Quiz Space

Java End Term: 28 April 2024 (January 2024 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 Java code given below.

java
class Product {
private String productName;
public Product(String pn) {
productName = pn;
}
public Product(Product p) {
this.productName = p.productName;
}
public void setProductName(String pn) {
productName = pn;
}
public String getProductName() {
return productName;
}
}
public class InventoryTest {
public static void main(String[] args) {
Product p1 = new Product("Laptop");
Product p2 = new Product(p1);
Product p3 = p1;
p1.setProductName("Smartphone");
System.out.println(p1.getProductName());
System.out.println(p2.getProductName());
System.out.println(p3.getProductName());
}
}

What will the output be?

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

Question 3

+4 marksOne correct option

Consider the Java code given below.

java
class Shape {
public void draw() {
System.out.println("Drawing a generic shape.");
}
public void area() {
System.out.println("Calculating area of the shape.");
}
}
class Circle extends Shape {
public void draw() {
System.out.println("Drawing a circle.");
}
}
class Square extends Shape {
public void draw() {
System.out.println("Drawing a square.");
}
}
public class ShapeApp {
static void describe(Shape sh) {
sh.draw();
sh.area();
}
public static void main(String[] args) {
Shape circle = new Circle();
Shape square = new Square();
describe(circle);
describe(square);
}
}

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 28 Apr 2024 paper

The IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 28 Apr 2024, in the January 2024 term: 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 28 Apr 2024 at a glance
TermJanuary 2024 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions23
Marks100
Duration180 min
MCQ19
MSQ4
Official paperIIT M FOUNDATION DIPLOMA FN EXAM QDF1 28 Apr 2024
Negative markingNo negative marking.
Updated

Same End Term, other subjects

More Java