Quiz Space

Java End Term: 1 September 2024, Set QDF1 (May 2024 term)

Question 1

+4 marksOne correct option

Consider the Java code given below.

java
class Monitor {
public void screenSize() {
System.out.println("Normal screen size");
}
public void resolution() {
System.out.println("Normal resolution");
}
}
class LCD extends Monitor {
public void screenSize() {
System.out.println("Screen size is large");
}
}
class LED extends Monitor {
public void screenSize() {
System.out.println("Screen size is medium");
}
public void resolution() {
System.out.println("HD resolution");
}
}
public class Test {
static void show(Monitor[] monitors) {
for (int i = 0; i < monitors.length; i++) {
monitors[i].screenSize();
monitors[i].resolution();
}
}
public static void main(String[] args) {
Monitor[] monitors = {new LCD(), new LED()}; // LINE 1
show(monitors);
}
}

Choose the correct option.

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

Question 2

+4 marksOne correct option

Consider the code given below that checks whether two candidates are from the same college. Method equals is overridden to compare two Candidate objects as follows. If two candidates are from the same college then they are said to be equal. Based on the given information, answer the question that follows.

java
class Candidate {
private String name;
private String college;
// Constructor to initialize instance variables
public String toString() {
return name;
}
public boolean equals(Object obj) {
// CODE BLOCK
}
}
public class Test {
public static void main(String[] args) {
Candidate c1 = new Candidate("Shreya", "IITMadras");
Candidate c2 = new Candidate("Hari", "IITDelhi");
Candidate c3 = new Candidate("Aisha", "IITMadras");
if (c1.equals(c3)) {
System.out.println(c1 + " and " + c3 + " belong to the same college");
}
if (c2.equals(c3)) {
System.out.println(c2 + " and " + c3 + " belong to the same college");
}
}
}

Choose the correct option to fill in place of CODE BLOCK so that the output is:

Shreya and Hari belong to the same college

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

Question 3

+4 marksOne correct option

Consider the Java code given below.

java
class Intern {
private String name;
public Intern(String n) {
name = n;
}
public Intern(Intern i) {
this.name = i.name;
}
public void setName(String n) {
name = n;
}
public String getName() {
return name;
}
}
public class Test {
public static void main(String[] args) {
Intern i1 = new Intern("Jaya");
Intern i2 = new Intern(i1);
Intern i3 = i1;
i1.setName("Subash");
System.out.println(i1.getName());
System.out.println(i2.getName());
System.out.println(i3.getName());
}
}

What will the output be?

  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 1 Sept 2024 Set QDF1 paper

The IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 1 Sept 2024, in the May 2024 term, set QDF1: 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 1 Sept 2024 Set QDF1 at a glance
TermMay 2024 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions23
Marks100
Duration180 min
MCQ18
MSQ5
Official paperIIT M FOUNDATION DIPLOMA AN EXAM QDF3 01 Sep 2024
Negative markingNo negative marking.
Updated

Other sets that day

Same End Term, other subjects

More Java