You are on page 1of 3

NPTEL : Programming In Java: Week 6 Solutions:

_____________________________________________
Quiz Answers:
______________________________________________

1) A
2) A,C
3) C,D
4) A
5) A,C
6) B
7) D
8) A
9) B
10) C

______________________________________________

PROGRAMS:
_______________________________________________
1)

public class Question61 extends Thread

public void run()


{
System.out.print("Thread is Running.");
}

____________________________________________

2)

public static void main(String[] args)


{
Question62 ex = new Question62();
Thread t0= new Thread(ex);
t0.setName("Main Thread");
t0.start();
System.out.println("Welcome to Java Week 6 New Question.");
t0.setName("Main Thread");
}

________________________________________________

3)

class MyThread extends B

{
public void run()
{System.out.print("NPTEL Java week-6 new Assignment Q3");} }

_______________________________________________

4)

public synchronized int sum()


{
return(a+b);
}
public synchronized void inc()
{
a++;
b++;
}
}

_________________________________________________

5)
t1.start();
t1.setName("Week 6 Assignment Q5");

t2.start();

t2.setName("Week 6 Assignment Q5 New");

You might also like