Quiz Space

Java Quiz 1: 16 October 2022 (September 2022 term)

Question 1

+3 marksOne correct option

Consider the Java code given below.

java
interface Readable{
public default void read(){
System.out.println("Reads");
}
}
interface Writable{
public default void write(){
System.out.println("Writes");
}
}
class Document implements Readable, Writable{
public void read(){
System.out.println("Reads the lines in doc");
}
}
public class Test {
public static void main(String[] args) {
Readable r1 = new Document();
r1.read();
r1.write();
}
}

Choose the correct option

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

Question 2

+3 marksOne correct option

Consider the Java code given below.

java
interface Iterator{
public boolean has_next();
public Object get_next();
}
class Faculty{
// ...
private class FacIter implements Iterator{
// ....
public boolean has_next() {
// ...
return false;
}
public Object get_next() {
// ...
}
}
public Iterator getIterator() {
return new FacIter();
}
}
public class Test{
public static void main(String[] args) {
Faculty fList = new Faculty();
//CODE BLOCK // LINE-1
boolean hasNext = iter.has_next(); // LINE-2
}
}

Identify the appropriate statements to fill in place of LINE-1 in order to correctly invoke method has_next() as given in LINE-2.

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

Question 3

+3 marksOne correct option

Consider the Java code given below.

java
class Experiment{
public void begin(){
Simulation s = new Simulation(this); // LINE 1
s.simulate();
System.out.println("Experiment finished");
}
public void alarm(){
System.out.println("Collected results");
}
}
class Simulation{
Experiment exp;
public Simulation(Experiment e){
exp = e;
}
public void simulate(){
System.out.println("Simulated Successfully");
exp.alarm(); // LINE 2
}
}
public class Test {
public static void main(String[] args) {
Experiment e1 = new Experiment();
e1.begin();
}
}

Choose the correct option.

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

12 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 Quiz 1 16 Oct 2022 paper

The IIT Madras BS Programming Concepts using Java (Java) Quiz 1 paper sat on 16 Oct 2022, in the September 2022 term: 15 questions for 50 marks in 120 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 Quiz 1 16 Oct 2022 at a glance
TermSeptember 2022 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions15
Marks50
Duration120 min
MCQ13
MSQ2
Official paperIIT M QUIZ 1 FOUNDATION DAD DIPLOMA QPD2 16 Oct 2022
Negative markingNo negative marking.
Updated

Same Quiz 1, other subjects

More Java