Sign Up

Sign In

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have permission to ask a question, You must login to ask a question.

SIKSHAPATH Latest Articles

NPTEL Programming In Java Week 6 Assignment Answers 2023

NPTEL Programming In Java Week 6 Assignment Answers 2023

Students, it’s time to take a closer look at the hint of programming in java NPTEL week 6 assignment answers. And, identify where you can improve your marks in this assignment.

Table of Contents

NPTEL Programming In Java Week 6 Assignment Answers

Q1. Which of the following is NOT TRUE in Java?

a. Every thread has a priority.
b. JVM allows multiple threads of execution running concurrently.
c. Threads with higher priority are executed first.
d. You cannot set a maximum priority value that a thread can have.

Answer: Option D.

1000+ students getting help from instant notifications, Join us on telegram.


Q2. Consider the following code:

class PrimeRun implements Runnable {
	long minPrime; 
PrimeRun (long minPrime) {
	this.minPrime = minPrime;
}
public void run() { 
// compute primes larger than minPrime
	}
}

Which of the following is TRUE regarding the above code?

Answer: a. Creating a thread in Java using Runnable interface
d. The class implements the run method.


Q3. Which of the following can be used to create an instance of Thread?

a. By implementing the Runnable interface.

b. By extending the Thread class.

c. By creating a new class named Thread and calling method run().

d. By importing the Thread class from the related package.

Answer: Option C & D.


Q4. Which method start () will do which of the following?

Answer: a. Causes this thread to begin execution.


Q5. Which method start () will do which of the following?

Answer: a. Causes this thread to begin execution.

c. The JVM calls the run method of this thread.


Q6. Which of the following is not platform independent in Java?

Answer: b. The thread constructor with the stackSize parameter is platform dependent.


Q7. The following is a simple program using the concept of thread.

public class Question extends Thread { 
public void run() { 
for (int i=1;i<5;i++) {
System.out.println(++i);
}
}
public static void main(String args[]) { 
Question t1=new Question ();
t1.run();
}

What is the output of the above program?

a. 1

3

b. 2

4

6

8

c. Runtime error

d. 2

4

Answer: Option D.


Q8. For the program given below, what will be the output after its execution?

public class Main{
public static void main(String[] args){
Thread thread=Thread.currentThread();
 thread.run();
System.out.print (thread.activeCount());
}
}

a. 1

b. 10

c. 01

d. 11

Answer: d. 11


Q9. Which of the following method returns a reference to the currently executing thread object?

Answer: b. public static Thread currentThread()


Q10. Which of the following methods can be used to reduce over-utilization of CPU?

Answer: c. public static void sleep(long millis)

NPTEL Java Week 6 Programming Assignment Answers

Q1.

public class Question61 extends Thread

 { 

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

Q2.

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");
    }

Q3.

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

Q4.

public synchronized int sum()
  
{
  return(a+b);
}



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

Q5.

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


  t2.start(); 


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

TELEGRAM FOR NOTIFICATIONClick Here
Follow on Google News (in one click)Click Here

Disclaimer: These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.


Also Available:

NPTEL Programming In Java Week 5 Assignment Answers

Related Posts

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock