Question 2
Consider the code given below.
class Enquiry{ int available = 1; public synchronized void request(int n, String name){ if(available >= n){ available = available - n; System.out.println(name + " booked " + n + " ticket"); } else{ System.out.println(name + " cannot book " + n + " ticket"); } }}class TicketBooking implements Runnable{ Enquiry e; String name; int n_tickets; public TicketBooking(Enquiry e1, String n, int t){ // constructor } public void run(){ e.request(n_tickets, name); }}public class Test{ public static void main(String[] args){ Enquiry obj = new Enquiry(); TicketBooking tb1 = new TicketBooking(obj, "Sita", 1); TicketBooking tb2 = new TicketBooking(obj, "Raju", 1); Thread t1 = new Thread(tb1); Thread t2 = new Thread(tb2); t2.start(); t1.start(); }}Which of the following options is/are possible result/s of the above code?
Question 3
Consider the code given below.
interface Displayable{ void display();}abstract class Delivery implements Displayable{ public abstract void deliver();}class Fpkart extends Delivery{ public void display() { System.out.println("Fpkart display"); } public void deliver() { System.out.println("Fpkart delivery"); }}class Amzn extends Delivery{ public void deliver() { System.out.println("Amzn delivery"); } public void display() { System.out.println("Amzn display"); }}public class User { // CODE BLOCK public static void main(String[] args) { showDetails(new Fpkart()); showDetails(new Amzn()); }}Choose the correct option to fill in place of CODE BLOCK so that the output is:
Fpkart delivery
Fpkart display
Amzn delivery
Amzn display
12 9 6 3
9 6 3 0
10 7 4 1
7 4 1 0
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 11 Dec 2022 Set ETD1 paper
The IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 11 Dec 2022, in the September 2022 term, set ETD1: 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.
| Feature | Java End Term 11 Dec 2022 Set ETD1 at a glance |
|---|---|
| Term | September 2022 term |
| Subject | Programming Concepts using Java |
| Course code | BSCS2005 |
| Questions | 23 |
| Marks | 100 |
| Duration | 180 min |
| MCQ | 20 |
| MSQ | 3 |
| Official paper | IIT M DIPLOMA AN1 EXAM ETD1 11 Dec 2022 |
| Negative marking | No negative marking. |
| Updated |