VTU Updates

Programming in Java NPTEL Assignment Answers of Week 6 (2023)

In this article, you will get  NPTEL Assignment Answers  of  Week 6 (2023)  of the course  Programming in Java

1. 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 : d. You cannot set a maximum priority value that a thread can have.

2. Consider the following code.

Which of the following is TRUE regarding the above code? a. Creating a thread in Java using Runnable interface b. Thread creation by declaring a class to be a subclass of Thread c. Overriding the run method of class Thread d. The class implements the run method.

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

3. Which of the following cannot 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 : c. By creating a new class named Thread and calling method run(). . d. By importing the Thread class from the related package.

4. Which method start () will do which of the following? a. Causes this thread to begin execution. b. Either start the execution for new thread or pause an ongoing thread. c. The JVM calls the run method of this thread. d. Recovers a thread from deadlock and begin execution

Answer : a. Causes this thread to begin execution.

5. Which method start () will do which of the following? a. Causes this thread to begin execution. b. Either start the execution for new thread or pause an ongoing thread. c. The JVM calls the run method of this thread. d. Recovers a thread from deadlock and begin execution

Answer : a. Causes this thread to begin execution. . c. The JVM calls the run method of this thread.

6. Which of the following is not platform independent in Java? a) Everything in Java thread is platform dependent. b) The thread constructor with the stackSize parameter is platform dependent. c) The inheritance in java is platform dependent as multiple classes are involved. d) There is no platform dependency in Java.

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

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

What is the output of the above program? a. 1 ㅤ3 b. 2 ㅤ4 ㅤ6 ㅤ8 c. Runtime error d. 2 ㅤ4

Answer : d. 2 ㅤ . 4

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

a. 1 b. 10 c. 01 d. 11

Answer : d. 11

9. Which of the following method returns a reference to the currently executing thread object? a. public static boolean interrupted() b. public static Thread currentThread() c. public final boolean isAlive() d. public final void suspend()

Answer : b. public static Thread currentThread()

10. Which of the following methods can be used to reduce over-utilization of CPU? a. public static void yield() b. public static void main(String args[]) c. public static void sleep(long millis) d. public void start()

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

Programming Assignment Answers

Week 6 : programming assignment 1.

Complete the code segment to print the following using the concept of extending the  Thread  class in Java: —————–OUTPUT——————-

Thread is Running.

————————————————-

Week 6 : Programming Assignment 2

In the following program, a thread class Question62 is created using the Runnable interface Complete the main() to create a thread object of the class Question62 and run the thread. It should print the output as given below.

—————–OUTPUT——————-

Welcome to Java Week 6 New Question.

Main Thread has ended.

Week 6 : Programming Assignment 3

A part of the Java program is given, which can be completed in many ways, for example using the concept of thread, etc.  Follow the given code and complete the program so that your program prints the message “NPTEL Java week-6 new Assignment Q3” . Your program should utilize the given interface/ class.

Week 6 : Programming Assignment 4

Execution of two or more threads occurs in a random order. The keyword ‘synchronized’ in Java is used to control the execution of thread in a strict sequence. In the following, the program is expected to print the output as given below. Do the necessary use of ‘synchronized’ keyword, so that, the program prints the Final sum as given below:  

Final sum:6000

Week 6 : Programming Assignment 5

Given a snippet of code, add necessary codes to print the following:

Name of thread ‘t1’:Thread-0

Name of thread ‘t2’:Thread-1

New name of thread ‘t1’:Week 6 Assignment Q5

New name of thread ‘t2’:Week 6 Assignment Q5 New

Related Posts

Angularjs application that displays the date.

  • March 12, 2024

AngularJS application to convert student details to Uppercase

Angularjs application that allows users to maintain a collection of items, leave a reply cancel reply.

Your email address will not be published. Required fields are marked *

Add Comment  *

Save my name, email, and website in this browser for the next time I comment.

Post Comment

Search code, repositories, users, issues, pull requests...

Provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

This site is to share the solution of prgramming and quiz assignment given during the Programming In java by Prof. Debasis Samantha on NPTEL.

bkkothari2255/Programming_In_Java_NPTEL

Folders and files, repository files navigation, programming_in_java_nptel.

Java

Navigate to Week

Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Week 8 Week 9 Week 10 Week 11 Week 12

Java Week 1:Q1 To find the perimeter and area of a circle given a value of radius.

Java Week 1:Q2 To find the largest among three numbers x, y, and z.

Java Week 1:Q3 Consider First n even numbers starting from zero(0) and calculate sum of all the numbers divisible by 3 from 0 to n. Print the sum.

Java Week 1:Q4 To check whether the number is an Armstrong number or not.

Java Week 1:Q5 To help Ram , find the highest mark and average mark secured by him in "s" number of subjects.

Java Week 2:Q1 To call the method print() in class Student following the concept of inner class.

Java Week 2:Q2 To call the method print() of class Student first and then call print() method of class School.

Java Week 2:Q3 To call print() method of class Question by creating a method named ‘studentMethod()’.

Java Week 2:Q4 To call default constructor first and then any other constructor in the class Answer.

Java Week 2:Q5 To debug the program which is intended to print 'NPTEL JAVA'.

Java Week 3:Q1 To the generation of Fibonacci numbers.

Java Week 3:Q2 Define a class Point with two fields x and y each of type double. Also , define a method distance(Point p1, Point p2) to calculate the distance between points p1 and p2 and return the value in double. Complete the code segment given below. Use Math.sqrt( ) to calculate the square root.

Java Week 3:Q3 A class Shape is defined with two overloading constructors in it. Another class Test1 is partially defined which inherits the class Shape. The class Test1 should include two overloading constructors as appropriate for some object instantiation shown in main( ) method. You should define the constructors using the super class constructors. Also, override the method calculate( ) in Test1 to calculate the volume of a Shape.

Java Week 3:Q4 This program to exercise the call of static and non-static methods. A partial code is given defining two methods, namely sum( ) and multiply ( ). You have to call these methods to find the sum and product of two numbers.

Java Week 3:Q5 To swap two numbers using call by object reference.

Java Week 4:Q1 To execute the following program successfully. You should import the correct package(s) and/or class(s) to complete the code.

Java Week 4:Q2 To print the current year.

Java Week 4:Q3 The program in this assignment is attempted to print the following output:

Java Week 4:Q4 To call the default method in the interface First and Second.

Java Week 4:Q5 To print the following output.

Java Week 5:Q1 An interface Number is defined in the following program. You have to declare a class A, which will implement the interface Number. Note that the method findSqr(n) will return the square of the number n.

Java Week 5:Q2 This program is to find the GCD (greatest common divisor) of two integers writing a recursive function findGCD(n1,n2). Your function should return -1, if the argument(s) is(are) other than positive number(s).

Java Week 5:Q3 Complete the code segment to catch the ArithmeticException in the following, if any. On the occurrence of such an exception, your program should print “Exception caught: Division by zero.” If there is no such exception, it will print the result of division operation on two integer values.

Java Week 5:Q4 In the following program, an array of integer data to be initialized. During the initialization, if a user enters a value other than integer value, then it will throw InputMismatchException exception. On the occurrence of such an exception, your program should print “You entered bad data.” If there is no such exception it will print the total sum of the array.

Java Week 5:Q5 In the following program, there may be multiple exceptions. You have to complete the code using only one try-catch block to handle all the possible exceptions.

For example, if user’s input is 1, then it will throw and catch “java.lang.NullPointerException“.

Java Week 6:Q1 Complete the code segment to print the following using the concept of extending the Thread class in Java:

Java Week 6:Q2 In the following program, a thread class ThreadRun is created using the Runnable interface which prints "Thread using Runnable interface". Complete the main class to create a thread object of the class ThreadRun and run the thread,

Java Week 6:Q3 A part of the Java program is given, which can be completed in many ways, for example using the concept of thread, etc. Follow the given code and complete the program so that your program prints the message "NPTEL Java". Your program should utilize the given interface/ class.

Java Week 6:Q4 Execution of two or more threads occurs in a random order. The keyword 'synchronized' in Java is used to control the execution of thread in a strict sequence. In the following, the program is expected to print some numbers. Do the necessary use of 'synchronized' keyword, so that, the program prints the output in the following order:

Java Week 6:Q5 Add necessary codes to print the following:

Java Week 7:Q1 Complete the following code fragment to read three integer values from the keyboard and find the sum of the values. Declare a variable "sum" of type int and store the result in it.

Java Week 7:Q2 Complete the code segment to catch the exception in the following, if any. On the occurrence of such an exception, your program should print “Please enter valid data” .If there is no such exception, it will print the "square of the number".

Java Week 7:Q3 A byte char array is initialized. You have to enter an index value"n". According to index your program will print the byte and its corresponding char value. Complete the code segment to catch the exception in the following, if any. On the occurrence of such an exception, your program should print “exception occur” .If there is no such exception, it will print the required output.

Java Week 7:Q4 The following program reads a string from the keyboard and is stored in the String variable "s1". You have to complete the program so that it should should print the number of vowels in s1 . If your input data doesn't have any vowel it will print "0".

Java Week 7:Q5 A string "s1" is already initialized. You have to read the index "n" from the keyboard. Complete the code segment to catch the exception in the following, if any. On the occurrence of such an exception, your program should print “exception occur” .If there is no such exception, your program should replace the char "a" at the index value "n" of the "s1" ,then it will print the modified string.

Java Week 8:Q1 Write a program which will print a pyramid of " " 's of height "n" and print the number of " " 's in the pyramid.

Java Week 8:Q2 Write a program which will print a pascal pyramid of "*" 's of height "l" .

Java Week 8:Q3 Write a program which will print a pyramid of "numbers" 's of height "n" and print the sum of all number's in the pyramid.

Java Week 8:Q4 Write a program to print symmetric Pascal's triangle of "*" 's of height "l" of odd length . If input "l" is even then your program will print "Invalid line number".

Java Week 8:Q5 Write a program to display any digit(n) from 0-9 using "7 segment display".

Java Week 9:Q1 Complete the code to develop a BASIC CALCULATOR that can perform operations like Addition, Subtraction, Multiplication and Division.

Java Week 9:Q2 Complete the code to develop an ADVANCED CALCULATOR that emulates all the functions of the GUI Calculator as shown in the image.

GUI Calculator

Java Week 9:Q3 Complete the code to perform a 45 degree anti clock wise rotation with respect to the center of a 5 × 5 2D Array as shown below:

Java Week 9:Q4 A program needs to be developed which can mirror reflect any 5 × 5 2D character array into its side-by-side reflection. Write suitable code to achieve this transformation as shown below:

Java Week 9:Q5 Write suitable code to develop a 2D Flip-Flop Array with dimension 5 × 5, which replaces all input elements with values 0 by 1 and 1 by 0. An example is shown below:

Java Week 10:Q1 The following code needs some package to work properly. Write appropriate code to import the required package(s) in order to make the program compile and execute successfully.

Java Week 10:Q2 Write the JDBC codes needed to create a Connection interface using the DriverManager class and the variable DB_URL. Check whether the connection is successful using 'isAlive(timeout)' method to generate the output, which is either 'true' or 'false'.

Java Week 10:Q3 Due to some mistakes in the below code, the code is not compiled/executable. Modify and debug the JDBC code to make it execute successfully.

Java Week 10:Q4 Complete the code segment to create a new table named ‘PLAYERS’ in SQL database using the following information.

Java Week 10:Q5 Complete the code segment to rename an already created table named ‘PLAYERS’ into ‘SPORTS’.

Java Week 11:Q1 Complete the code segment to insert the following data using prepared statement in the existing table ‘PLAYERS’.

Java Week 11:Q2 Write the required code in order to update the following data in the table ‘PLAYERS’.

Java Week 11:Q3 Write the appropriate code in order to delete the following data in the table ‘PLAYERS’.

Java Week 11:Q4 Complete the following program to calculate the average age of the players in the table ‘PLAYERS’.

Structure of Table 'PLAYERS' is given below:

Java Week 11:Q5 Complete the code segment to drop the table named ‘PLAYERS’.

Java Week 12:Q1 Complete the code to develop an extended version of the ADVANCED CALCULATOR with added special functions that emulates all the functions of the GUI Calculator as shown in the image.

GUI Calculator

Java Week 12:Q2 A partial code fragment is given. The URL class object is created in try block.You should write appropriate method( ) to print the protocol name and host name from the given url string.

Java Week 12:Q3 Write a program to create a record by taking inputs using Scanner class as first name as string ,last name as string ,roll number as integer ,subject1 mark as float,subject2 mark as float. Your program should print in the format

Java Week 12:Q4 A program code is given to call the parent class static method and instance method in derive class without creating object of parent class. You should write the appropriate code so that the program print the contents of static method() and instance method () of parent class.

Java Week 12:Q5 Write a recursive function to print the sum of first n odd integer numbers. The recursive function should have the prototype

Contributors 2

@bkkothari2255

  • Monday, April 1, 2024

NPTEL Programming in Java Week 6 Assignment Solution 2023

NPTEL-Programming-In-Java-Week6-Programming-Assignment-Solutions

NPTEL Programming in Java Week 6 All Programming Assignment Solutions – Jan 2023 | Swayam. With the growth of Information and Communication Technology, there is a need to develop large and complex software.

Further, those software should be platform independent, Internet enabled, easy to modify, secure, and robust. To meet this requirement object-oriented paradigm has been developed and based on this paradigm the Java programming language emerges as the best programming environment.

Now, Java programming language is being used for mobile programming, Internet programming, and many other applications compatible to distributed systems.

This course aims to cover the essential topics of Java programming so that the participants can improve their skills to cope with the current demand of IT industries and solve many problems in their own filed of studies.

COURSE LAYOUT

  • Week 1 : Overview of Object-Oriented Programming and Java
  • Week 2 : Java Programming Elements
  • Week 3 : Input-Output Handling in Java
  • Week 4 : Encapsulation
  • Week 5 : Inheritance
  • Week 6 : Exception Handling
  • Week 7 : Multithreaded Programming
  • Week 8 : Java Applets and Servlets
  • Week 9 : Java Swing and Abstract Windowing Toolkit (AWT)
  • Week 10 : Networking with Java
  • Week 11: Java Object Database Connectivity (ODBC)
  • Week 12: Interface and Packages for Software Development

Course Name : “Programming in Java 2023”

Question : 1  Complete the code segment  to print the following using the concept of extending the  Thread  class in Java:

—————–OUTPUT——————-

Thread is Running.

————————————————-

Question : 2   In the following program, a thread class  Question62  is created using the Runnable interface  Complete the main() to create a thread object of the class Question62 and run the thread. It should print the output as given below.

Welcome to Java Week 6 New Question.

Main Thread has ended.

Question : 3  A part of the Java program is given, which can be completed in many ways, for example using the concept of thread, etc.  Follow the given code and complete the program so that your program prints the message “ NPTEL Java week-6 new Assignment Q3 “. Your program should utilize the given interface/ class. Invalid HTML tag: tag name o:p is not allowed

Question : 4 Execution of two or more threads occurs in a random order. The keyword ‘synchronized’ in Java is used to control the execution of thread in a strict sequence. In the following, the program is expected to print the output as given below. Do the necessary use of ‘synchronized’ keyword, so that, the program prints the Final sum as given below: 

Final sum:6000

Question : 5   Given a snippet of code, add necessary codes to print the following:

Name of thread ‘t1’:Thread-0

Name of thread ‘t2’:Thread-1

New name of thread ‘t1’:Week 6 Assignment Q5

New name of thread ‘t2’:Week 6 Assignment Q5 New

IMAGES

  1. PROGRAMMING IN JAVA NPTEL WEEK 6 ASSIGNMENT ANSWERS 2023

    nptel week 6 java assignment answers

  2. NPTEL Programming in Java Week 6 Quiz Assignment Solutions || August

    nptel week 6 java assignment answers

  3. NPTEL Programming In Java Week 6 Assignment Solution Quiz

    nptel week 6 java assignment answers

  4. NPTEL Programming In Java Week 6 Assignment Solution

    nptel week 6 java assignment answers

  5. Programming in Java|| NPTEL WEEK-6 Quiz assignment Answers 2021||#

    nptel week 6 java assignment answers

  6. Programming in Java 2021

    nptel week 6 java assignment answers

VIDEO

  1. Nptel Programming in Java Week 2 Assignment 2 Answers and Solutions 2024

  2. NPTEL Programming In Java WEEK3 Programming Assignment Solutions

  3. NPTEL Programming In Java Week 12 Assignment 12 Answers Solution Quiz

  4. NPTEL Introduction to Machine Learning

  5. NPTEL Software Engineering Week 0 assignment answers

  6. NPTEL Programming In Java Week 6 Programming Assignment Answers Solution

COMMENTS

  1. bkkothari2255/Programming_In_Java_NPTEL

    Java Week 6:Q3 A part of the Java program is given, which can be completed in many ways, for example using the concept of thread, etc. Follow the given code and complete the program so that your program prints the message "NPTEL Java". Your program should utilize the given interface/ class.

  2. NPTEL Programming in Java Week 6 Assignment Solution 2023

    February 27, 2023. Faheem Ahmad. NPTEL Programming in Java Week 6 All Programming Assignment Solutions – Jan 2023 | Swayam. With the growth of Information and Communication Technology, there is a need to develop large and complex software. Further, those software should be platform independent, Internet enabled, easy to modify, secure, and ...