[go: up one dir, main page]

0% found this document useful (0 votes)
963 views3 pages

JAVA Week 6 Solutions

This document contains the solutions to quiz questions and programming assignments for NPTEL's Java week 6 course. It lists the answers to 10 multiple choice quiz questions. It then provides the code for 5 programming assignments which demonstrate threading concepts in Java such as extending the Thread class, setting thread names, and using synchronized methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
963 views3 pages

JAVA Week 6 Solutions

This document contains the solutions to quiz questions and programming assignments for NPTEL's Java week 6 course. It lists the answers to 10 multiple choice quiz questions. It then provides the code for 5 programming assignments which demonstrate threading concepts in Java such as extending the Thread class, setting thread names, and using synchronized methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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