Verifying that you are not a robot...

Navigation Menu

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 You must be signed in to change notification settings

Here are the assignment answers you need.

vklsaravanan/nptel-programmingInJava

Folders and files.

NameName
132 Commits

Repository files navigation

nptel

Programming In Java

Exercise1_1 - Complete the code segment to find the perimeter and area of a circle given a value of radius. Exercise1_2 - Complete the code segment to find the largest among three numbers x,y, and z. You should use if-then-else construct in Java. Exercise1_3 - Consider First n even numbers starting from zero(0).Complete the code segment to calculate sum of all the numbers divisible by 3 from 0 to n. Print the sum. Exercise1_4 - Complete the code segment to check whether the number is an Armstrong number or not. Exercise1_5 - Complete the code segment to help Ragav , find the highest mark and average mark secured by him in "s" number of subjects.

Exercise2_1 - Complete the code segment to call the method print() of class Student first and then call print() method of class School. Exercise2_2 - Complete the code segment to call the method print() of class given class Printer to print the following. Exercise2_3 - Complete the code segment to call print() method of class Question by creating a method named ‘studentMethod()’. Exercise2_4 - Complete the code segment to call default constructor first and then any other constructor in the class. Exercise2_5 - Complete the code segment to debug / complete the program which is intended to print 'NPTEL JAVA'.

Excercise3_1 - This program is related to the generation of Fibonacci numbers.>For example: 0,1, 1,2, 3,5, 8, 13,… is a Fibonacci sequence where 13 is the 8th Fibonacci number. Exercise3_2 - 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. Exercise3_3 - A class Shape is defined with two overloading constructors in it. Another class Test1 is partially defined which inherits the class Shape. The ..., Exercise3_4 - 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......, Exercise3_5 - Complete the code segment to swap two numbers using call by object reference.

Exercise4_1 - Complete the code segment to execute the following program successfully. You should import the correct package(s) and/or class(s) to complete the code. Exercise4_2 - Complete the code segment to print the current year. Your code should compile successfully. Exercise4_3 - The program in this assignment is attempted to print the following output: Exercise4_4 - Complete the code segment to call the default method in the interface First and Second. Exercise4_5 - Modify the code segment to print the following output.

Exercise5_1 - 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. Exercise5_2 - 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. Exercise5_3 - 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. Exercise5_4 - 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.., Exercise5_5 - 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.

Exercise6_1 - Complete the code segment to print the following using the concept of extending the Thread class in Java: Exercise6_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. Exercise6_3 - Given a snippet of code, add necessary codes to print the following: -----------------OUTPUT------------------- 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 ------------------------------------------------- Exercise6_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 .., Exercise6_5 - 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.

Exercise7_1 - 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. Exercise7_2 - 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". Exercise7_3 - 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.., Exercise7_4 - The following program reads a string from the keyboard and is stored in the String variable "s1".., Exercise7_5 -A string "s1" is already initialized. You have to read the index "n" from..,

Exercise8_1 - Write a program which will print a pyramid of " " 's of height "n" and print the number of " " 's in the pyramid. Exercise8_2 - Write a program which will print a pascal pyramid of " " 's of height "l" . Exercise8_3 - 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. Exercise8_4 - 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". Exercise8_5 - Write a program to display any digit(n) from 0-9 represented as a "7 segment display".

Exercise9_1 - Complete the code to develop a BASIC CALCULATOR that can perform operations like Addition, Subtraction, Multiplication and Division. Exercise9_2 - Complete the code to develop an ADVANCED CALCULATOR that emulates all the functions of the GUI Calculator as shown in the image. Exercise9_3 - 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: Exercise9_4 - 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: Exercise9_5 - 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:

Exercise10_1 - 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. Exercise10_2 - 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) Exercise10_3 - 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. Exercise10_4 - Complete the code segment to rename an already created table named ‘PLAYERS’ into ‘SPORTS’. Exercise10_5 - Complete the code segment to rename an already created table named ‘PLAYERS’ into ‘SPORTS’.

nptel java assignment answers week 3

Author @vklsaravanan
Connect with me:
  • Java 100.0%

' src=

  • All Courses
  • Privacy Policy

' src=

Swayam Solver

Learn Programming & Prepare for NPTEL Exams... Swayam Solver is your one-stop destination for NPTEL exam preparation.

NPTEL Programming In Java Programming Assignment July-2024 Swayam

NPTEL   »   Programming in Java

   Please scroll down for latest Programs.  👇 

Week 01 : Programming Assignment 1

Write a Java program to print the area and perimeter of a rectangle.

Public Test CasesInputExpected OutputActual OutputStatus
Private Test cases used for EvaluationStatus
Test Case 1

Week 01 : Programming Assignment 2

Write a Java program and compute the sum of an integer's digits.

Week 01 : Programming Assignment 3

Write a Java program to display n terms of natural numbers and their sum.

(Remember to match the output given exactly, including the spaces and new lines)

(passed with presentation error means you will get full marks)

Week 01 : Programming Assignment 4

Write a Java program to make such a pattern like a right angle triangle with the number increased by 1.

(Ignore presentation errors for this and all future programming assignments) (passed with presentation error means  you will get full marks )

Week 01 : Programming Assignment 5

Write a Java program to convert an integer number to a binary number.

Week 02 : Programming Assignment 1

Complete the code segment to call the method  display() of class Former first and then call display() method of class Latter.

Week 02 : Programming Assignment 2

Create a  class Student  with  private  attributes for  name  and  age .

Use a constructor to initialize these attributes and provide public getter methods to access them.

In the main method, an instance of Student is created and the student's details are printed.

Guideline to Solve:

§   Define the  Student class  with  private  attributes.

§   Use a constructor to initialize the attributes.

§   Implement getter methods for the attributes.

Follow the naming convetion used in the Fixed code.

Week 02 : Programming Assignment 3

Create a class  Rectangle  with attributes  length  and  width .

Provide two constructors: one with no parameters ( default to 1 ) and

another with parameters to initialize the attributes.

Use the  this  keyword to avoid name space collision.

Create a getArea() function that returns the area of the rectangle.

§   Define the  Rectangle  class with attributes and constructors.

§   Define a default Rectangle constructor that inializes length and width to 1.

§   Use the  this  keyword in the parameterized constructor.

§   Define a getArea() funtion that returns the area of there rectangle

Week 02 : Programming Assignment 4

Create a class  Circle  that encapsulates the properties of a circle.

The class should have a private field for the radius, a constructor to initialize the radius, and methods to calculate the area and circumference of the circle.

NOTE: use Math.PI for PI calculations (DO NOT USE 22/7)

§   Define the  Circle  class with attributes and constructors.

§   Define a getArea() funtion that returns the area of there Circle (use Math.PI)

§   Define a getCircumference() funtion that returns the circumference of there Circle (use Math.PI)

Week 02 : Programming Assignment 5

Complete the code by creating the constructor and the getter functions for a class Dog as defined below.

Week 03 : Programming Assignment 1

Create a class Department having a method  getCourses  that prints  "These are the department's courses" . It will have two subclasses , ComputerScience and MechanicalEngineering , each having a method with the same name that prints specific courses for the respective departments.Call the method by creating an object of each of the three classes.

Week 03 : Programming Assignment 2

Week 03 : programming assignment 3.

Write a program to print the factorial of a number by defining a recursive method named 'Factorial'.

Factorial of any number n is represented by n! and is equal to 1*2*3*....*(n-1)*n. E.g.-

4! = 1*2*3*4 = 24

3! = 3*2*1 = 6

2! = 2*1 = 2

Week 03 : Programming Assignment 4

Write a program to take integer inputs from user until he/she presses q ( Ask to press q to quit after every integer input ). Print average and product of all numbers.

Week 03 : Programming Assignment 5

Write a Java program to create a class called Employee with methods called work() and getSalary(). Create a subclass called HRManager that overrides the work() method and adds a new method called addEmployee().

Week 04 : Programming Assignment 1

Complete the code segment to swap two numbers using call by object reference.

Week 04 : Programming Assignment 2

1 - Problem Statement:        

Define a class  Point  with members

§   private double x;

§   private double y;

and methods:

§   public Point(double x, double y){}  // Constructor to create a new point?

§   public double slope(Point p2){} // Function to return the slope of the line formed from current Point and another Point (Assume that input will always be chosen so that slope will never be infinite)

Week 04 : Programming Assignment 3

This program to exercise the create static and non-static methods. A partial code is given, you have to define two methods, namely sum( ) and multiply( ). These methods have been called to find the sum and product of two numbers. Complete the code segment as instructed.  

Week 04 : Programming Assignment 4

The program in this assignment is attempted to print the following output:

-----------------OUTPUT-------------------

This is large

This is medium

This is small

This is extra-large

-------------------------------------------------

However, the code is intentionally with some bugs in it. Debug the code to execute the program successfully.

Week 04 : Programming Assignment 5

Consider First n even numbers starting from zero(0).Complete the code segment to calculate sum of  all the numbers divisible by 3 from 0 to n. Print the sum. Example:

Input: n = 5

Even number divisible by 3:0 6

Week 05 : Programming Assignment 1

Public Test CasesInputExpected OutputActual OutputStatus

Week 05 : Programming Assignment 2

Write a program to create an interface Searchable with a method search(String keyword) that searches for a given keyword in a text document. Create two classes Document and WebPage that implement the Searchable interface and provide their own implementations of the search() method.

Week 05 : Programming Assignment 3

Week 05 : programming assignment 4, week 05 : programming assignment 5, week 06 : programming assignment 1, week 06 : programming assignment 2, week 06 : programming assignment 3, week 06 : programming assignment 4, week 06 : programming assignment 5, week 07 : programming assignment 1, week 07 : programming assignment 2.

Write a program to print Swastika Pattern in Java. 

Input is 2 numbers. 

(Rows and Columns)

For Example:

   * *

NOTE: Do not print any spaces between the ‘*’

Output should match exactly as specified by the question

Week 07 : Programming Assignment 3

Write a program to remove all occurrences of an element from array in Java.

Week 07 : Programming Assignment 4

Write a p rogram to compute the sum of all prime numbers in a given range. The range value will be positive.

Follow the naming convention as given in the main method of the suffix code.

Week 07 : Programming Assignment 5

Code to create two threads, one printing even numbers and the other printing odd numbers.

§   The PrintNumbers class is declared, and it implements the Runnable interface. This interface is part of Java's concurrency support and is used to represent a task that can be executed concurrently by a thread.

§   Create a constructor of this class that takes two private instance variables (start and end) to represent the range of numbers that will be printed by the thread.

§   Create a run method that is required by the Runnable interface and contains the code that will be executed when the thread is started. In this case, it should prints odd numbers within the specified range (start to end) using a for loop.

§   Hint: Thread.currentThread().getName() returns the name of the currently executing thread, which is useful for identifying which thread is printing the numbers.

No comments:

Post a comment.

Keep your comments reader friendly. Be civil and respectful. No self-promotion or spam. Stick to the topic. Questions welcome.

Category: Nptel Assignment Answers 2024

Problem solving through programming in c nptel week 6 assignment answers, the joy of computing using python nptel assignment 6 answers, cloud computing nptel week 6 assignment answers, computer architecture week 6 assignment nptel answers 2024, cyber security and privacy week 6 nptel answers 2024, nptel data science for engineers assignment 6 answers, nptel database management system assignment 6 answers, deep learning for computer vision week 6 nptel answers, deep learning iit ropar week 6 nptel answers, digital circuits week 6 nptel assignment answers.

DBC Itanagar

All India News

NPTEL Programming in Java Week 3 Assignment Answers 2024

admin

1. What will be the output of the following program?

a. Static Method b. Throws a NullPointerException c. Compile-time error d. Run time error

2. What will be the output of the below program.

a. value of a = 20 b. error: cannot assign a value to final variable ‘a’ c. error: unknown variable ‘a’ in class subDemoClass d. value of a = 40

3. All the variables of interface should be?

a. default and final b. default and static c. public, static and final d. protect, static and final

4. What will be the output of the below program.

a. 7 7.4 b. 6 6.4 c. 7 9 d. 9 7

5. What will be the output of the following Java code?

a. 2 3 b. 3 3 c. Runtime Error d. Compilation Error

6. If a variable of primitive datatype in Java is declared as final, then

a. It cannot get inherited b. Its value cannot be changed c. It cannot be accessed in the subclass d. All of the above

7. Members which are not intended to be inherited are declared as

a. Public members b. Protected members c. Private members d. Private or Protected members

8. If a base class is inherited in protected access mode then which among the following is true?

a. Public and Protected members of base class becomes protected members of derived class b. Only protected members become protected members of derived class c. Private, Protected and Public all members of base, become private of derived class d. Only private members of base, become private of derived class

9. Which type of inheritance leads to diamond problem?

a. Single level b. Multi-level c. Multiple d. Hierarchical

10. What will be the output of the below program:

a. error: func() in subDemoClass cannot override func() in superDemoClass b. value of b = 60 c. value of a = 20 d. None of the above

NPTEL Product Design and Development Week 3 Assignment Answers

Leave a Reply Cancel reply

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

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

Latest News

NPTEL Introduction to Operating Systems Week Assignment Answers

NPTEL Introduction to Operating Systems Week 7 Assignment Answers 2024

NPTEL Learning Analytics Tools Week 1 Assignment Answers

NPTEL Learning Analytics Tools Week 7 Assignment Answers 2024

NPTEL Conservation Geography Week 2 Assignment Answers

NPTEL Conservation Geography Week 7 Assignment Answers 2024

NPTEL Theory of Computation Week 2 Assignment Answers

NPTEL Theory of Computation Week 7 Assignment Answers 2024

NPTEL Wild Life Ecology Week 1 Assignment Answers 2024

NPTEL Wild Life Ecology Week 7 Assignment Answers 2024

nptel java assignment answers week 3

Sign in to your account

Username or Email Address

Remember Me

  • Saturday, September 7, 2024

NPTEL Programming in Java Week3 Assignment Solution 2023

Programming-In-Java-Week3-Programming-Assignment-Solutions

NPTEL Programming in Java Week3 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 This program is related to the generation of Fibonacci numbers.

For example: 0,1, 1,2, 3,5, 8, 13,… is a Fibonacci sequence where 13 is the 8 th  Fibonacci number.

Question : 2  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.

Question : 3 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.

Question : 4 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. Complete the code segment as instructed. 

Question : 5 Complete the code segment to swap two numbers using call by object reference.

Quizermania Logo

Programming in Java | NPTEL 2023 | Week 3 quiz solutions

This set of MCQ(multiple choice questions) focuses on the  Programming in Java NPTEL 2023 Week 3 Quiz Solutions .

Course layout (Answers Link)

Answers COMING SOON! Kindly Wait!

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

NOTE:  You can check your answer immediately by clicking show answer button. Programming in Java NPTEL 2023 Week 3 Quiz Solutions” contains 10 questions.

Now, start attempting the quiz.

Programming in Java NPTEL 2022 Week 1 Quiz Solutions

Q1. In which of the following scenario(s), the static block is used in Java?

a) To create static variables b) To initialize instance variables c) To initialize static variables d) To create new objects

Answer: c) To initialize static variables

Q2. Consider the following piece of code. Fill in the blank with the appropriate keyword(s) from the list given below so that the program compiles successfully.

a) public void b) private void c) public static void d) private static void

Answer: c), d)

Q3. What is the output of the above code?

a) A’s display method B’s display method b) A’s display method A’s dispaly method c) B’s display method B’s display method d) B’s display method A’s display method

Q4. Which of the following statement(s) is/are false?

a) You can write a new instance method in the subclass with the same signature as the one in the superclass, thus overriding it b) You can write a new static method in the subclass with the same signature as the one in the superclass, thus hiding it c) A subclass inherits all of its parent’s public and protected memebers, no matter what package the subclass is in d) You cannot declare new methods in the subclass that are not in the superclass

Q5. Which of the following statement(s) is/are true?

a) You will get a compile-time error if you attempt to change an instance method in the superclass to a static method in the subclass b) You can prevent a class from being subclassed by using the final keyword in the class’s declaration c) An abstract class can be instantiated d) Common behaviour can be defined in a superclass and inherited into a subclass using the extends keyword

Answer: a), b), d)

Q6. What is the output of the above program?

a) prgam b) program c) gramm d) ing in

Answer: a) prgam

Q7. Which of the following is the output of the above program?

a) 10 100 b) 10 20 c) 100 10 d) 10 19

Q8. If the program is executed, then what will be the output from the execution?

a) 1700 b) 1300 c) 0 d) 2600

Answer: a) 1700

Q9. Which of the following statement(s) is/are true?

a) Hiding internal data from the outside world and accessing it only through publicly exposed methods is known as data encapsulation b) Static methods in interfaces are never inherited c) The term “class variable” is another name for a non-static field d) A local variable stroes a temporary state; it is declared inside a method

Answer: a), c), d)

Q10. All classes in java are inherited from which class?

a) java.lang.class b) java.class.inherited c) java.class.object d) java.lang.object

Programming in Java NPTEL 2023 Week 3 Quiz Solutions

Q1. Which of the following statement(s) is/are correct about the constructor?

a) Constructors cannot be synchronized in Java b) Java does not provide a default copy constructor c) A constructor cannot be overloaded d) “this” or “super” can be used in a constructor

Q2. Which of the following statement(s) is/are true?

a) You can write a new instance method in the subclass with the same signature as the one in the superclass, thus overriding it. b) You can write a new static method in the subclass with the same signature as the one in the superclass, thus hidiing it. c) A subclass inherits all of its parent’s public and protected members, no matter what package the subclass is in. d) You cannot declare new methods in the subclass that are not in the superclass.

Answer: a), b), c)

Q3. Fill in the blank with the appropriate keyword(s) from the list given below so that the program compiles successfully.

a) abstract b) final c) default d) public

Answer: b), d)

Q4. How many instances of abstract class can be created?

a) 0 b) 1 c) 2 d) Multiple

Q5. Structure a Java class such that only methods within the class can access its instance variables is referred to as ________.

a) Object orientation b) inheritance c) platform independence d) encapsulation

Q6. Which of the following statement(s) is/are true?

a) A final method cannot be overridden in a subclass b) The advantage of private static methods is that they can be reused later if you need to reinitialize the class variable c) Class methods cannot use this keyword as there is no instance for this refer to d) A final method can be overridden in a subclass

a) Java b) There will be a compile-time error c) JavaJava d) The program will give a runtime error

Q8. What is the output of the above program?

a) java b) ring c) r min d) gram

Q9. Which of the following statement(s) is/are False?

a) Hiding internal data from the outside world and accessing it only through publicly exposed methods is known as data encapsulation b) Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword c) The term “class variable” is another name for a non-static field d) A local variable stores a temporary state; it is declared inside a method.

Q10. Which of the following statement(s) is/are true?

a) Static methods in interfaces are never inherited b) You will get a compile-time error if you attempt to change an instance method in the superclass to a static method in the subclass c) You can prevent a class from being subclassed by using the final keyword in the class’s declaration d) An abstract class can only be subclassed; it cannot be instantiated

Answer: a), b), c), d)

Programming in Java NPTEL 2022 Week 3 Quiz Solutions

Q1. Which of this keyword can be used in a sub class to call the constructor of super class?

a) super b) this c) extent d) extends

Answer: a) super

Q2. What is the output of the above program?

a) i+j is 42 4 0 b) i+j is 6 9 2 c) i+j is 42 9 2 d) i+j is 6 4 0

Q3. What is the output of the above program?

a) 4 b) 10 c) 2 d) runtime error

Answer: c) 2

Q4. For each description on the left, find the best matching modifier on the right. You may use a choice more than once or not at all.

a) 1-A, 2-A, 3-C, 4-D, 5-E b) 1-A, 2-A, 3-A, 4-B, 5-C c) 1-C, 2-B, 3-A, 4-A, 5-D d) None of Above

Answer: b) 1-A, 2-A, 3-A, 4-B, 5-C

Q5. All the variables of interface should be?

a) default and final b) default and static c) public, static and final d) protect, static and final

Answer: c) public, static and final

Q6. Which of the following statement(s) is/are NOT true?

a) A final method cannot be overridden in a subclass. b) The advantage of private static methods is that they can be reused later if you need to reinitialize the class variable. c) Class methods cannot use this keyword as there is no instance for this to refer to. d) A final method can be overridden in a subclass.

Answer: d) A final method can be overridden in a subclass.

Q7. Which of the following statements is/are true?

a) Hello b) There will be a compile-time error c) HelloHello d) The program will give a runtime error

Answer: d) The program will give a runtime error

Q8. Which of the following option is true about the above program?

a) Error: String cannot be a method return type like void, int, char, etc.; as it is a class. b) Error: Non-static variable ‘answer’ cannot be referenced from a static context. c) Output: The answer to the question. Which course have you opted? is Programming with Java d) Error: Compilation error as variable ‘question’ is not static.

Answer: c) Output: The answer to the question. Which course have you opted? is Programming with Java

Q9. Disadvantage(s) of inheritance in Java programming is/are

a) Code readability b) two classes (base and inherited class) get tightly coupled c) Save development time and effort d) Code reusability

Answer: b) two classes (base and inherited class) get tightly coupled

Q10. Which inheritance in Java programming is not supported?

a) Multiple inheritance using classes. b) Multiple inheritance using interfaces. c) Multilevel inheritance d) Single inheritance

Answer: a) Multiple inheritance using classes.

Previous Course – Week 3 Quiz Solutions

Q1. Consider the following piece of code in Java.

What is the output of the above program?

a) 2 3 b) 3 3 c) Runtime Error d) Compilation Error

Answer: b) 3 3

Q2. Consider the following piece of code in Java.

a) 6 b) 10 c) 21 d) error

Answer: a) 6

Q3. If a class inheriting an abstract class does not define all of its functions then it will be known as?

a) Default b) Abstract c) A simple class d) Static class

Answer: b) Abstract

Q4. Which among the following best describes polymorphism?

a) It is the ability for many messages/data to be processed in one way b) It is the ability for a message/data to be processed in only 1 form c) It is the ability for a message/data to be processed in more than one form d) It is the ability for undefined message/data to be processed in at least one way

Answer: c) It is the ability for a message/data to be processed in more than one form

Q5. Consider the following piece of code in Java

a) 30 b) 20 c) Compile error d) Runtime error

Answer: c) Compile error

Programming in Java NPTEL 2022 Week 3 quiz Solutions

Q6. All the variables of the interface should be?

Q7. Disadvantage(s) of inheritance in Java programming is/are

a) Code readability b) two classes (base and inherited class) get tightly coupled c) Code maintainability d) Code reusability

Programming in Java NPTEL 2022 Week 3 Quiz solutions

Q8. When does method overloading is determined?

a) At run time b) At coding time c) At compile time d) At execution time

Answer: c) At compile time

Which of the following statements is/are true?

a) Output: Hello b) Program will compile successfully c) There will be a compile-time error d) The program will give a runtime error

a) Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as data encapsulation b) Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword c) The term “class variable” is another name for static field d) A local variable stores temporary state; it is declared inside a method

>> Next- Programming in Java Week 2 Assignment Solutions

>> Next- Programming in Java Week 4 Assignment Solutions

For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.

Related Posts

Html mcq : html basics (multiple choice question), html mcq : html web browsers (multiple choice question).

Preprocessor Directives

C programming MCQ : Preprocessor Directives(MULTIPLE CHOICE QUESTION)

C++ mcq : c++ basics(multiple choice question), 1 thought on “programming in java | nptel 2023 | week 3 quiz solutions”.

' src=

Please share assignment 3 programming answers

Leave a Comment Cancel Reply

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

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

  • 1st Central Law Reviews: Expert Legal Analysis & Insights

NPTEL Programming In Java Assignment 3 Answers July 2023

NPTEL Programming In Java Assignment 3 Answers July 2023:-  All the Answers are provided here to help the students as a reference, You must submit your assignment at your own knowledge

ALSO READ :- NPTEL Registration Steps [July – Dec 2022] NPTEL Exam Pattern Tips & Top Tricks [2022] NPTEL Exam Result 2022 | NPTEL Swayam Result Download

NPTEL Programming In Java Week 3 Quiz Assignment Answers 2023

1. In which of the following scenario(s), the static block is used in Java? a. To create static variables. b. To initialize instance variables. c. To initialize static variables. d. To create new objects.

2. Consider the following piece of code.

Fill in the blank with the appropriate k eyword(s) from the list given below so that the program compiles successfully. a. public void b. private void c. public static void d. private static void

3. Consider the following piece of code.

What is the output of the a b ove code? a. A’s display method B’s display method b. A’s display method A’s display method c. B’s display method B’s display method d. B’s display method A’s display method

4. Which of the following statements) is/are false? a. You can write a new instance method in the subclass with the same signature as the one in the superclass, thus overriding it. b. You can write a new static method in the subclass with the same signature as the one in the superclass, th u s hiding it. c. A subclass inherits all of its parent’s public and protected members, no matter what package the subclass is in. d. You cannot declare new methods in the subclass that are not in the superclass.

5. Which of the following statement(s) is/are true? a. You will get a compile-time error if you attempt to change an instance method in the superclass to a static method in the subclass. b. You can prevent a clas s from being subclassed by using the final keyword in the class’s declaration. c. An abstract class can be instantiated. d. Common behaviour can be defined in a superclass and inherited into a subclass using the extends keyword.

6. Consider the following program.

What is the output of the abo v e program? a. prgam b. program c. gramm d. ing in

7. Consider the following piece of code.

NPTEL Programming In Java Assignment 3 Answers July 2023

Which of the following is the output of the abo v e program? a. 10 100 b. 10 20 c. 100 1 0 d. 10 10

8. Consider the following program.

If the program is executed, then w h at will be the output from the execution? a. 1700 b. 1300 c. 0 d. 2600

9. Which of the following statement(s) is/are true? a. Hiding internal data from the outside world and accessing it only through publicly exposed methods is known as data encapsulation. b. Static methods in interfaces are never inherited. c. The term “class variable” is another name for a non-s t atic field. d. A local variable stores a temporary state; it is declared inside a method.

10. All classes in java are inherited from which class? a. java.lang.class b. java.class.inherited c. java.class . object d. java.lang.Object

NPTEL Programming In Java Week 3 Programming Assignment Solutions 2023

Q1. This program is related to the generation of Fibonacci numbers.

For example: 0,1, 1,2, 3,5, 8, 13,… is a Fibonacci sequence where 13 is the 8th Fibonacci number.

A partial code is given and you have to complete the code as per the instruction given .

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.

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.

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. Complete the code segment as instructed.

Q5. Complete the code segment to swap two numbers using call by object reference.

NPTEL Programming In Java Assignment 3 Answers [July 2022]

1. Which of this keyword can be used in a sub class to call the constructor of super class? a. super b. this c. extent d. extends

2. What is the output of the above program? a. i+jis 42 4 b. i+jis6 9 2 c. i+jis 42 9 2 d. i+jis 6 4

Answers will be Uploaded Shortly and it will be Notified on Telegram, So  JOIN NOW

NPTEL Programming In Java Assignment 3 Answers July 2023

3. What is the output of the above program? a. 4 b. 10 c. 2 d. runtime error

4. For each description on the left, find the best matching modifier on the right. You may use a choice more than once or not at all. 1. Hides the instance variable from code in other files. A. private 2. Hides the method from code in other files B. public 3. Hides the subclass from code in other files. C. final 4. Exposes the API method to code in other files. D. static 5. Prevents the value of the instance variable from being Changed once initialized. E. none of the above a. 1-A.2-A.3-C.4-D5-E b. 1-A.2-A,3-A,4-B,5-C c. 1-C.2-B.3-A, 4-A,5-D d. None of Above

5. All the variables of interface should be? a) default and final b) default and static c) public, static and final d) protect, static and final

6. Which of the following statement(s) is/are NOT true? a. A final method cannot be overridden in a subclass. b. The advantage of private static methods is that they can be reused later if you need to reinitialize the class variable. c. Class methods cannot use this keyword as there is no instance for this to refer to. d. A final method can be overidden in a subclass.

👇 For Week 04 Assignment Answers 👇

7. Which of the following statements is/ are true? a. Hello b. There will be a compile-time error c. HelloHello. d. The program will give a runtime error.

8. Which of the following option is true about the above program? a. Eror: String cannot be a method return tpe like void, int, char, etc.; as it isa class. b. Eror: Non-static variable ‘answer’ cannot be referenced from a static context. C. Output: The answer to the question, Which course have you opted? is Programming with Java d. Error: Compilation error as variable question’ is not static.

9. Disadvantage(s) of inheritance in Java programming is/are a) Code readability b) two classes (base and inherited class) get tightly coupled c) Save development time and effort d) Code reusability

10. Which inheritance in Java programming is not supported? a. Multiple inheritance using classes. b. Multiple inheritance using interfaces. c. Multilevel inheritance. d. Single inheritance.

NPTEL Programming In Java Assignment 3 Programming Solutions

Q1. This program is related to the generation of Fibonacci numbers. For example: 0,1, 1,2, 3,5, 8, 13,… is a Fibonacci sequence where 13 is the 8 th  Fibonacci number. A partial code is given and you have to complete the code as per the instruction given below.

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. Complete the code segment as instructed.  

What is Programming In Java?

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.

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of best 8 assignments out of the total 12 assignments given in the course. Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.

NPTEL Programming In Java Assignment 2 Answers Jan 2022

Q1. Consider the following piece of code in Java.

What is the output of the above program?

a) 2 3 b) 3 3 c) Runtime Error d) Compilation Error

Answer:- b) 3 3

👇 FOR NEXT WEEK ASSIGNMENT ANSWERS 👇

Q2. Consider the following piece of code in Java.

a) 6 b) 10 c) 21 d) error

Answer:- a) 6

Q3. If a class inheriting an abstract class does not define all of its functions then it will be known as?

a) Default b) Abstract c) A simple class d) Static class

Answer:- b) Abstract

Q4. Which among the following best describes polymorphism?

a) It is the ability for many messages/data to be processed in one way b) It is the ability for a message/data to be processed in only 1 form c) It is the ability for a message/data to be processed in more than one form d) It is the ability for undefined message/data to be processed in at least one way

Answer:- c) It is the ability for a message/data to be processed in more than one form

Q5. Consider the following piece of code in Java

a) 30 b) 20 c) Compile error d) Runtime error

Answer:- c) Compile error

Q6. All the variables of the interface should be?

a) default and final b) default and static c) public, static and final d) protect, static and final

Answer:- c) public, static and final

Q7. Disadvantage(s) of inheritance in Java programming is/are

a) Code readability b) two classes (base and inherited class) get tightly coupled c) Code maintainability d) Code reusability

Answer:- b) two classes (base and inherited class) get tightly coupled

Q8. When does method overloading is determined?

a) At run time b) At coding time c) At compile time d) At execution time

Answer:- c) At compile time

Which of the following statements is/are true?

a) Output: Hello b) Program will compile successfully c) There will be a compile-time error d) The program will give a runtime error

Answer:- (B) & (D)

Q10. Which of the following statement(s) is/are true?

a) Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as data encapsulation b) Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword c) The term “class variable” is another name for static field d) A local variable stores temporary state; it is declared inside a method

Answer:- (C) & (D)

Disclaimer :- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.

For More NPTEL Answers:-  CLICK HERE

Join Our Telegram:-  CLICK HERE

Programming In Java Assignment 2 Answers 2022:-  All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge

If you found this article Interesting and helpful, don’t forget to share it with your friends to get this information.

Leave a Comment Cancel reply

You must be logged in to post a comment.

Please Enable JavaScript in your Browser to Visit this Site.

Spread the word.

Share the link on social media.

Confirm Password *

Username or email *

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 Logo

SIKSHAPATH Latest Articles

Nptel programming in java week 3 assignment answers 2023.

NPTEL Programming in Java Assignment Answer

Are you looking for help in Programming In Java NPTEL Week 3 Assignment Answers? So, here in this article, we have provided Programming In Java week 3 Assignment Answer’s hint.

Table of Contents

NPTEL Programming In Java Week 3 Assignment Answers

Q1. Which of the following statement(s) is/are correct about the constructor?

Answer : a. Constructors cannot be synchronized in Java. b. Java does not provide a default copy constructor.

d. “this” or “super” can be used in a constructor.

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

Q2. Which of the following statement(s) is/are true?

Answer : a. You can write a new instance method in the subclass with the same signature as the one in the superclass, thus overriding it. b. You can write a new static method in the subclass with the same signature as the one in the superclass, thus hiding it. c. A subclass inherits all of its parent’s public and protected members, no matter what package the subclass is in.

Q3. Consider the following piece of code.

Fill in the blank with the appropriate keyword(s) from the list given below so that the program compiles successfully.

Answer: b. final d. public

Q4. How many instances of abstract class can be created?

Answer: a. 0

Q5. Structuring a Java class such that only methods within the class can access its instance variables is referred to as _______.

Answer: d. encapsulation

Q6. Which of the following statement(s) is/are true?

Answer: a. A final method cannot be overridden in a subclass. b. The advantage of private static methods is that they can be reused later if you need to reinitialize the class variable. c. Class methods cannot use this keyword as there is no instance for this to refer to.

Q7. Consider the following piece of code.

Which of the following is the output of the above program?

Answer: b. There will be a compile-time error.

Q8. Consider the following program.

What is the output of the above program?

Answer: b. ring

Q9. Which of the following statement(s) is/are False?

Answer: c. The term “class variable” is another name for a non-static field.

Q10. Which of the following statement(s) is/are true?

Answer: a. Static methods in interfaces are never inherited. b. You will get a compile-time error if you attempt to change an instance method in the superclass to a static method in the subclass. c. You can prevent a class from being subclassed by using the final keyword in the class’s declaration. d. An abstract class can only be subclassed; it cannot be instantiated.

Programming In Java Week 3 Programming Assignment Answers

(in one click)

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 2 Assignment Answers

NPTEL Java week 4 assignment answers

Related Posts

NPTEL Programming In Java Week 6 Assignment Answers 2023

NPTEL Programming In Java Week 6 Assignment Answers 2023

NPTEL Cloud Computing and Distributed Systems Assignment 6 Answers 2023

NPTEL Cloud Computing and Distributed Systems Assignment 6 Answers 2023

NPTEL Cloud Computing Assignment 5 Answers 2023

NPTEL Cloud Computing Assignment 5 Answers 2023

IMAGES

  1. NPTEL Programming In Java Week 3 Programming Assignment Answers Solution

    nptel java assignment answers week 3

  2. NPTEL PROGRAMMING IN JAVA WEEK 3 ASSIGNMENT ANSWERS

    nptel java assignment answers week 3

  3. NPTEL Programming in Java Assignment Week 3 Answers

    nptel java assignment answers week 3

  4. NPTEL Programming in Java Week 3 Quiz Assignment Solutions || August 2020 || Swayam

    nptel java assignment answers week 3

  5. Programming In Java Nptel Week 3 Assignment Answers 2024

    nptel java assignment answers week 3

  6. Programming in Java|| WEEK-3 Quiz assignment Answers 2020||NPTEL||#

    nptel java assignment answers week 3

VIDEO

  1. NPTEL Programming In Java Week 9 Programming Assignment Answers Solution

  2. NPTEL Programming In Java Week 7 Programming Assignment Answers Solution

  3. NPTEL Programming In Java WEEK8 Quiz Assignment Solutions💡

  4. NPTEL Java week 01 programming assignment 3 solutions #nptel #aboutcomputercode

  5. NPTEL Programming In Java WEEK3 Quiz Assignment Solutions💡

  6. Programming In Java

COMMENTS

  1. NPTEL Programming in Java Week 3 Assignment Solution July 2024

    Welcome to our detailed walkthrough of the "NPTEL Programming in Java Week 3 Assignment Solution for July 2024," presented by IIT Kharagpur. This video is ta...

  2. Programming in Java| NPTEL| WEEK 3 ASSIGNMENT| solution

    In this video, I walk you through the solution to Nptel Week 3 assignment, providing detailed explanations for each question. The answers have been carefully...

  3. NPTEL Programming in Java Week 3 Programming Assignment ...

    Welcome to our detailed walkthrough of the "NPTEL Programming in Java Week 3 Programming Assignment Solution for July 2024," presented by IIT Kharagpur. This...

  4. Programming in Java Nptel Week 3 Assignment Answers

    Find the latest and accurate solutions for your Week 3 assignment in the Programming in Java course offered by Nptel. See the questions and answers for July-Dec 2024, Jan-Apr 2024 and previous years.

  5. Programming in Java NPTEL Assignment Answers of Week 3 (2023)

    Find the solutions for the programming assignment questions of week 3 of the course Programming in Java offered by NPTEL. The answers include code segments, explanations and output for various topics such as constructors, inheritance, encapsulation, static methods and Fibonacci numbers.

  6. GitHub

    These files contain the assignment answers for each respective week. Select the Week File: Click on the file corresponding to the week you are interested in. For example, if you need answers for Week 3, open the week-03.md file. Review the Answers: Each week-XX.md file provides detailed solutions and explanations for that week's assignments ...

  7. GitHub

    Find the complete code segments for the weekly exercises of NPTEL programming in Java course. The repository contains solutions for topics such as control structures, methods, constructors, inheritance, interfaces, exceptions, threads, and more.

  8. NPTEL Programming In Java Programming Assignment July-2024 Swayam

    Learn Programming & Prepare for NPTEL Exams... Swayam Solver is your one-stop destination for NPTEL exam preparation. NPTEL Programming In Java Programming Assignment July-2024 Swayam Posted on July 22, 2024 . ... Week 02 : Programming Assignment 3. Due on 2024-08-08, 23:59 IST.

  9. Programming in Java Week 3 Assignment Answers

    Welcome to our channel! In this video, we provide detailed answers and explanations for the Week 3 assignment of the NPTEL course on "Programming in Java." W...

  10. Category: Nptel Assignment Answers 2024

    Find NPTEL assignment answers and solutions for various courses and weeks on Progiez.com. Browse through the categories and get the answers for week 3 of theory of computation, joy of computing, data structure and algorithms, and more.

  11. NPTEL Programming in Java Week 3 Assignment Answers 2024

    a. error: func () in subDemoClass cannot override func () in superDemoClass. b. value of b = 60. c. value of a = 20. d. None of the above. Answer :- For Answers Click Here. TAGGED: NPTEL Programming in Java Week 3 Assignment Answers. Share This Article.

  12. NPTEL Programming in Java Week3 Assignment Solution 2023

    Course Name : "Programming in Java 2023". Question : 1 This program is related to the generation of Fibonacci numbers. For example: 0,1, 1,2, 3,5, 8, 13,… is a Fibonacci sequence where 13 is the 8th Fibonacci number. Question : 2 Define a class Point with two fields x and y each of type double. Also, define a method distance (Point p1 ...

  13. Programming in Java

    Week 10: Networking with Java. Week 11: Java Object Database Connectivity. Week 12: Interface and Packages for Software Development. NOTE: You can check your answer immediately by clicking show answer button. Programming in Java NPTEL 2023 Week 3 Quiz Solutions" contains 10 questions. Now, start attempting the quiz.

  14. PDF Java Week 3: Q4

    02/07/2020 Programming in Java - Course https://onlinecourses.nptel.ac.in/noc20_cs08/progassignment?name=110 3/3 DOWNLOAD VIDEOS Assignment Solution

  15. NPTEL Programming In Java Assignment 3 Answers July 2023

    NPTEL Programming In Java Week 3 Programming Assignment Solutions 2023. Q1. This program is related to the generation of Fibonacci numbers. For example: 0,1, 1,2, 3,5, 8, 13,… is a Fibonacci sequence where 13 is the 8th Fibonacci number. A partial code is given and you have to complete the code as per the instruction given .

  16. NPTEL Programming In Java WEEK3 Programming Assignment Solutions

    🔊 Programming In Java NPTEL Elective Course 2023 | GATE NPTEL | https://techiestalk.in/NPTEL Programming In Java WEEK3 Programming Assignment Solutions | Sw...

  17. NPTEL Programming In Java Week 3 Assignment Answers 2023

    NPTEL Programming In Java Week 3 Assignment Answers. Q1. Which of the following statement (s) is/are correct about the constructor? Answer: a. Constructors cannot be synchronized in Java. b. Java does not provide a default copy constructor. d. "this" or "super" can be used in a constructor.

  18. NPTEL Programming In Java Week 3 Assignment 3 Answers ...

    Programming In Java Week 3 Assignment 3 Answers Solution Quiz | 2024-JanJoin NPTEL - Programming in Java :https://telegram.me/ProgrammingInJavaNPTELJoin our ...

  19. PDF Week 3 Programming Assignment

    Week 4 Quiz Week 4 Programming Assignment Week 5: Exception handling, input/output, file handling, string processing Week 5 Programming Assignment Week 6: Backtracking, scope, data structures; stacks, queues and heaps Week 6 Quiz Week 7: Classes, objects and user defined datatypes Week 7 Quiz Week 8: Dynamic programming, wrap-up Week 8 ...