Quiz Space

Java End Term: 24 December 2023, Set FDD1 (September 2023 term)

Question 1

+5 marksOne correct option

Consider the Java code given below.

java
import java.util.*;
import java.util.stream.*;
class Player {
private String name;
int point;
//Constructor to initialize instance variables
public String toString() {
return name;
}
}
public class Test {
public static void main(String[] args) {
var pArr = new ArrayList<Player>();
pArr.add(new Player("Sharan", 150));
pArr.add(new Player("Virat", 500));
pArr.add(new Player("Rahul", 100));
pArr.add(new Player("Sanju", 250));
Map<Boolean, List<Player>> playMap;
playMap = pArr.stream()
.collect(Collectors.partitioningBy(p -> p.point >= 250));
System.out.println(playMap.get(false));
}
}

Choose the correct option.

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

Question 2

+5 marksOne correct option

Consider the code given below.

java
class Doctor implements Cloneable{
private String name;
private String[] qualification ;
public Doctor(String n, String[] q) {
name = n;
qualification = q;
}
//method setName(String name) to initialize name
//method setQualification(int indx,String q) to initialize
//qualification at a particular index
//method getName() to return name
//method getQualification(int indx) to return qualification
//at a particular index
public Object clone() throws CloneNotSupportedException{
return super.clone();
}
}
public class Testclone {
public static void main(String[] args) throws CloneNotSupportedException{
String[] q = {"MBBS", "MD", "M.Ch"};
Doctor d1 = new Doctor("Mathew", q);
Doctor d2 = (Doctor)d1.clone();
Doctor d3 = d1;
d2.setQualification(1, "MS");
d3.setName("John");
System.out.println(d1.getName() + " " + d1.getQualification(1));
System.out.println(d2.getName() + " " + d2.getQualification(1));
System.out.println(d3.getName() + " " + d3.getQualification(1));
}
}

Choose the correct option.

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

Question 3

+5 marksOne correct option

Method Stream.iterate(e, f) returns an infinite sequential ordered Stream produced by iterative application of a function f to an initial element e, producing a Stream consisting of e, f(e), f(f(e)), ...
Based on the above information, consider the code given below, and answer the question that follows.

java
import java.util.stream.*;
public class Test {
public static void main(String[] args) {
Stream.iterate(10, n -> n - 1)
.map(n -> n * 3)
.filter(n -> n % 5 == 0)
.limit(4)
.forEach(x -> System.out.print(x + " "));
}
}

What will the output be?

  1. A

    10 5 0 -5

  2. B

    30 27 24 21

  3. C

    30 15 0 -15

  4. D

    0 -15 -30 -45

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 24 Dec 2023 Set FDD1 paper

The IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 24 Dec 2023, in the September 2023 term, set FDD1: 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 24 Dec 2023 Set FDD1 at a glance
TermSeptember 2023 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions23
Marks100
Duration180 min
MCQ19
MSQ4
Official paperIIT M DIPLOMA FN EXAM FDD1 24 Dec 2023
Negative markingNo negative marking.
Updated

Other sets that day

Same End Term, other subjects

More Java