Quiz Space

Java End Term: 7 August 2022, Set QPD1 (May 2022 term)

Question 1

+3 marksOne correct option

Consider the Java code given below.

java
class Customer{
private String name;
public Customer(String n){
this.name = n;
}
public Customer(Customer c){
this.name = c.name;
}
public void setName(String n){
name = n;
}
public String getName(){
return name;
}
}
public class Test{
public static void main(String[] args){
Customer c1 = new Customer("Latha");
Customer c2 = c1;
Customer c3 = new Customer(c1);
c1.setName("Geeta");
System.out.println("c2.name : " + c2.getName());
System.out.println("c3.name : " + c3.getName());
}
}

What will the output be?

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

Question 2

+3 marksOne correct option

Assume that the file “test.txt” contains the following two lines of text.

text
M.S Dhoni is a professional Indian cricketer
M.S Dhoni is from jharkhand

Consider the code given below.

java
import java.io.*;
import java.util.*;
public class FileTest {
public static void main(String[] args) {
try {
var in=new FileInputStream("test.txt");
var sc=new Scanner(in);
var data=new TreeSet<String>();
while(sc.hasNext()) {
data.add(sc.next()+" ");
}
for(String str:data)
System.out.print(str);
} catch (FileNotFoundException e) {
System.out.println("File does not exist.");
}
catch (IOException e) {
System.out.println("Error in writing a file.");
}
}
}

What will the output be?

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

Question 3

+3 marksOne correct option

Consider the following java code

java
import java.util.stream.*;
public class Main{
public static void main(String[] args){
Integer[] a = {11, 8, 20, 13, 6};
Stream.of(a)
.map((i) -> i - 8).filter((i) -> i% 2 == 0)
.forEach((x) -> System.out.println(x));
}
}

What will the output be?

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

19 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 7 Aug 2022 Set QPD1 paper

The IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 7 Aug 2022, in the May 2022 term, set QPD1: 22 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 7 Aug 2022 Set QPD1 at a glance
TermMay 2022 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions22
Marks100
Duration180 min
MCQ14
MSQ8
Official paperIIT M FOUNDATION DIPLOMA ENDTERM QPD1 07 Aug 2022 IBA NS
Negative markingNo negative marking.
Updated

Other sets that day

Same End Term, other subjects

More Java