Aug 2, 2024 · NPTEL Programming in Java Week 2 Assignment Answers 2024. 1. Which of the following is the correct way to declare a class in Java? a. public class MyClass {} b. class MyClass[] {} c. public MyClass class {} d. MyClass public class {} Answer :- a ... 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 ... ... Feb 4, 2023 · Excited for NPTEL’s Java programming week 2 quiz assignment answers? Look no further! I’ve got you covered with probable answers for all 10 questions. Use these as a helpful guide in completing your assignment with confidence before the deadline. ... Feb 8, 2023 · 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 ... ... 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’. WEEK 3. Java Week 3:Q1 To the generation of Fibonacci numbers. ... Aug 5, 2023 · Answer :- a NPTEL Programming In Java Week 2 Programming Assignment Answers. 1. Complete the code segment to call the method print() of class Student first and then call print() method of class School. Solution:-class School { // This is a method in class School public void print() { System.out.println("Hi! I class SCHOOL."); ... Java Week 2:Q1 Complete the code segment to call the method print() of class Student. ... The due date for submitting this assignment has passed. ... //swayam.gov.in ... ... ">

VTU Updates

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

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

1. Following is a program given for this question.

What will be the output of the above program?

a. 22221010 b. 12222101 c. 22101010 d. 22221012

Answer:  a. 22221010

2. When an array is passed to a method, what value does the method receive?

a. Reference of the array. b. Copy of the array. c. First element in the array. d. Length of the array.

Answer : a. Reference of the array.

3. Following is a program given for this question.

a. 28 b. -29 c. 30 d. -31

Answer:  c. 30

4. How many bits are needed for float and double in Java, respectively?

a. 32 and 64 b. 32 and 32 c. 64 64 d. 64 and 32

Answer:  a. 32 and 64

5. Which of the following is a valid automatic type conversion in Java?

a. short to byte b. float to long c. int to short d. int to long

Answer:  d. int to long

6. Consider the following program and identify the output.

a. 5 b. 10 c. 50 d. Compilation error

Answer:  d. Compilation error

7. Which of the following is a valid declaration of an object of class say, Student?

a. Student obj = new Student; b. Student obj = new Student(); c. obj = new Student(); d. new Student obj;

Answer:  b. Student obj = new Student();

8. What is the output of the following program?

a. 210 b. 120 c. 012 d. 201

Answer:  c. 012

9. Consider the following piece of code.

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

a. java b. npteljava c. nptel java d. nptel

Answer:  d. nptel

10. What is the output of the following program?

a. 60 b. 3011 c. 33 d. Compilation error

Programming Assignment Answers

Week 2 : programming assignment 1.

Complete the code segment to call the method   print()  of class School first  and then call  print()   method of class Student .

Week 2 : Programming Assignment 2

Complete the code segment  to call the method   print()  of class given class Printer to print the following.

——————————–

Hi! I am class SCHOOL

Hi! I class STUDENT. ——————————–

Week 2 : Programming Assignment 3

Complete the code segment to call print() method of class Question by creating a method named  ‘student()’.

Week 2 : Programming Assignment 4

Complete the code segment  to call default constructor first and then any other constructor in the class.

Week 2 : Programming Assignment 5

Complete the code segment to  debug / complete the program which is intended to print ‘NPTEL JAVA’.

Related Posts

NPTEL Data Science Using Python Answers

NPTEL Data Science Using Python Answers

  • August 6, 2024

NPTEL Data Science Using Python – Week 2: Assignment 2 Answers

Nptel data science using python – week 1 : assignment 1 answers, 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

Programming in Java Nptel Week 2 Assignment Answers

Are you looking for Programming in Java Nptel Week 2 Assignment Answers? You’ve come to the right place! Access the latest and most accurate solutions for your Week 2 assignment in the Programming in Java course

Course Link: Click Here

Table of Contents

Programming in Java Nptel Week 2 Assignment Answers

Programming in Java Nptel Week 2 Assignment Answers (July-Dec 2024)

Q1. Which of the following is the correct way to declare a class in Java? a. public class MyClass {} b. class MyClass[] {} c. public MyClass class {} d. MyClass public class {}

Answer: a. public class MyClass {}

Q2. What is the purpose of a constructor in a class? a. To destroy objects of the class b. To create static methods c. To implement inheritance d. To initialize objects of the class

Answer: d. To initialize objects of the class

For answers or latest updates join our telegram channel: Click here to join

These are Programming in Java Nptel Week 2 Assignment Answers

Q3.Which keyword is used in Java to refer to the current object? a. that b. self c. current d. this

Answer: d. this

Q4.Consider the following code snippet. What will be the output? a. 0 b. 10 c. Compilation error d. Runtime error

Answer: b. 10

Q5. Which of the following demonstrates constructor overloading in Java? a. Defining multiple constructors in a class with different parameter lists b. Defining multiple methods in a class with the same name c. Defining a constructor in a subclass d. Using the super keyword

Answer: a. Defining multiple constructors in a class with different parameter lists

Q6. What is the purpose of the this keyword in the context of avoiding name space collision? a. To call another constructor in the same class b. To refer to the current object c. To differentiate between instance variables and parameters with the same name d. To import another class

Answer: c. To differentiate between instance variables and parameters with the same name

Q7. Which of the following is the correct signature of the main method in Java? a. public void main(String[] args) b. public static void main(String[] args) c. public static void main() d. public main(String[] args)

Answer: b. public static void main(String[] args)

Q8. Which class is used in Java to take runtime data input from the user? a. BufferReader b. UserInputStreamReader c. Scanner d. DataInputStreamReader

Answer: c. Scanner

Q9. What is the output of the following Java code snippet? (\n in output is to be assumed to be the new line character)

a. Hello World\nNumber: 10 b. Hello WorldNumber: 10 c. Hello \nWorld\nNumber: 10 d. Hello World\nNumber: 10\n

Answer: a. Hello World\nNumber: 10

Q10. How do you read a line of text from the console using the Scanner class in Java? a. scanner.readLine() b. scanner.nextLine() c. scanner.getLine() d. scanner.fetchLine()

Answer: b. scanner.nextLine()

All Weeks of Programming In Java: Click Here

For answers to additional Nptel courses, please refer to this link:  NPTEL Assignment Answers

Programming in Java Nptel Week 2 Assignment Answers (Jan-Apr 2024 )

Course name: Programming In Java

Course Link:  Click Here

For answers or latest updates join our telegram channel:  Click here to join

These are NPTEL Programming In Java Week 2 Assignment Answers

Q1. In Java programming an object can take many forms. This feature is called  _______ . a. Abstraction b. Polymorphism c. Encapsulation d. Inheritance

Answer: b. Polymorphism

Q2. Which of the following is a valid declaration of an object of class, say NPTEL? a. NPTEL obj = new NPTEL(); b. NPTEL obj = new NPTEL; c. obj = new NPTEL(); d. new NPTEL obj;

Answer: a. NPTEL obj = new NPTEL();

Q3. A default constructor_______________________. a. has no arguments b. has no return type c. has one argument but no return type d. has two arguments

Answer: a. has no arguments

Q4. A top-level class may have which one of the following access modifiers? a. package b. private c. protected d. public

Answer: d. public

Q5. Integer in Java is a\an __________. a. Adapter class b. Inner class c. Not a class d. Wrapper class

Answer: d. Wrapper class

Q6. What is true about the new operator? a. returns a pointer to a variable b. creates a variable called new c. obtains memory for a new variable d. tells how much memory is available

Answer: c. obtains memory for a new variable

Q7. Which one is not supported by OOP? a. Abstraction b. Polymorphism c. Encapsulation d. Global variables

Answer: d. Global variables

Q8. Which of the following modifiers can be used to disallow a method from being overridden? a. final b. transient c. volatile d. static

Answer: a. final

Q9. Consider the following code segment Identify the line number(s) where there is/are error(s) in the above code. a. 1 b. 2 c. 3 d. 4 and 5

Answer: b. 2

Q10. Which of the following is TRUE about print() and println() methods? a. print() prints in a single line only and multiple lines cannot be printed in any way. b. println() prints and then appends a line break. c. println() prints in a single line only and multiple lines cannot be printed. d. print() prints and then appends a line break.

Answer: b. println() prints and then appends a line break.

More Weeks of Programming In Java:  Click here

More Nptel Courses:  https://progiez.com/nptel-assignment-answers

Programming in Java Nptel Week 2 Assignment Answers (July-Dec 2023 )

Course Name: Programming In Java

These are NPTEL Programming In Java Week 2 Assignment 2 Answers

Programming Assignment

Question 1 Complete the code segment to call the method print() of class Student first and then call print() method of class School.

Question 2 Complete the code segment  to call the method  print()  of class given class Printer to print the following. ——————————– Hi! I am class STUDENT Hi! I class SCHOOL. ——————————–

Question 3 Complete the code segment to call print() method of class Question by creating a method named ‘studentMethod()’.

Question 4 Complete the code segment to call default constructor first and then any other constructor in the class.

Question 5 Complete the code segment to debug / complete the program which is intended to print ‘NPTEL JAVA’.

More Nptel Courses:  Click here

Programming in Java Nptel Week 2 Assignment Answers (Jan-Apr 2023 )

Course Name: Programming in Java

Week 3:  Click Here

Q1. Following is a program given for this question. What will be the output of the above program? a. 22221010 b. 12222101 c. 22101010 d. 22221012

Answer: a. 22221010

Q2. When an array is passed to a method, what value does the method receive? a. Reference of the array. b. Copy of the array. c. First element in the array. d. Length of the array.

Answer: a. Reference of the array.

Q3. Following is a program given for this question. What will be the output of the above program? a. 28 b. -29 c. 30 d. -31

Answer: c. 30

Q4. How many bits are needed for float and double in Java, respectively? a. 32 and 64 b. 32 and 32 c. 64 and 64 d. 64 and 32

Answer: a. 32 and 64

Q5. Which of the following is a valid automatic type conversion in Java? a. short to byte b. float to long c. int to short d. int to long

Answer: d. int to long

Q6. Consider the following program and identify the output. a. 5 b. 10 c. 50 d. Compilation error

Answer: d. Compilation error

Q7. Which of the following is a valid declaration of an object of class say, Student? a. Student obj = new Student; b. Student obj = new Student(); c. obj = new Student(); d. new Student obj;

Answer: b. Student obj = new Student();

Q8. What is the output of the following program? a. 210 b. 120 c. 012 d. 201

Answer: c. 012

Q9. Consider the following piece of code. Which of the following option is the output of the above program? a. java b. npteljava c. nptel java d. nptel

Answer: d. nptel

Q10. What is the output of the following program? a. 60 b. 3011 c. 33 d. Compilation error

Programming In Java Programming Assignment Solution

Complete the code segment to call the method print() of class School first and then call print() method of class Student.

Complete the code segment to call the method print() of class given class Printer to print the following. ——————————– Hi! I am class SCHOOL Hi! I class STUDENT. ——————————–

Complete the code segment tocall print() method of class Question by creating a method named ‘student()’.

Complete the code segment to call default constructor first and then any other constructor in the class.

Complete the code segment to debug / complete the program which is intended to print ‘NPTEL JAVA’.

More Weeks of Programming In Java:  Click Here

Programming in Java Nptel Week 2 Assignment Answers (July-Dec 2022)

Q1.  What is the output of the following program?

a) 88 b) 8010 c) 64 d) 810

Answer: c) 64

Q2.  Which of the following is generate API documentation in HTML format from Java source code?

a) javac b) javadoc c) javap d) java

Answer: b) javadoc

Q3.  Following is a program given for this question.

What will be the output of the above program?

a) javanptel b) npteljava c) janjavanptel d) jannpteljava

Answer: b) npteljava

Q4.  What will happen during the execution of the following code for the command line input?

Consider the following input on command line and select the options with the correct output(s).

Input: A: “jan java nptel” B:  1 2 3

a) A : jannptel javanptel nptelnptel b) A : jan java nptel jan java nptel c) B : 11 21 31 d) B : 1 2 3 1

Answer: b), c)

Q5.  Which of the following is/are TRUE about print() and println() methods?

a) print() prints in a single line only and multiple lines cannot be printed in any way. b) print() prints and then appends a line break. c) println() prints in a single line only and multiple lines cannot be printed. d) println() prints and then appends a line break.

Answer: d) println() prints and then appends a line break.

Q6.  What was the initial name of Java when it was first developed for embedded systems?

a) Greentalk b) Oak c) Java d) Javac

Answer: a) Greentalk

Q7.  Which of the following is a valid declaration of an object of class, say Foo?

a) Foo obj = new Foo; b) obj = new Foo(); c) Foo obj = new Foo(); d) new Foo obj;

Answer: c) Foo obj = new Foo();

Programming in Java Nptel Week 3 Assignment Answers

Quizermania Logo

Programming in Java | NPTEL 2022 | Week 2 Assignments Solutions

This article will help you with the solutions of the  Programming in Java NPTEL 2022 Week 2 Assignment .

Programming in Java NPTEL Week 2 Programming Assignment 1 Solutions

Complete the code segment to call the method   print()  of class Student first  and then call  print()   method of class School .

Week 2: Programming Assignment 2 Solution

Complete the code segment  to call the method   print()  of class given class Printer to print the following. ——————————– Hi! I am class STUDENT Hi! I class SCHOOL. ——————————–

Week 2: Programming Assignment 3 Solution

Complete the code segment to call print() method of class Question by creating a method named  ‘studentMethod()’.

Week 2: Programming Assignment 4 Solution

Complete the code segment  to call default constructor first and then any other constructor in the class.

Week 2: Programming Assignment 5 Solution

Complete the code segment to  debug / complete the program which is intended to print ‘NPTEL JAVA’.

The above question set contains all the correct answers. But in any case, you find any typographical, grammatical or any other error in our site then kindly  inform us . Don’t forget to provide the appropriate URL along with error description. So that we can easily correct it.

Thanks in advance.

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), 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

DBC Itanagar

All India News

NPTEL Programming in Java Week 2 Assignment Answers 2024

admin

1. Which of the following is the correct way to declare a class in Java?

a. public class MyClass {} b. class MyClass[] {} c. public MyClass class {} d. MyClass public class {}

2. What is the purpose of a constructor in a class?

a. To destroy objects of the class b. To create static methods c. To implement inheritance d. To initialize objects of the class

3. Which keyword is used in Java to refer to the current object?

a. that b. self c. current d. this

4. Consider the following code snippet. What will be the output?

a. 0 b. 10 c. Compilation error d. Runtime error

5. Which of the following demonstrates constructor overloading in Java?

a. Defining multiple constructors in a class with different parameter lists b. Defining multiple methods in a class with the same name c. Defining a constructor in a subclass d. Using the super keyword

6. What is the purpose of the this keyword in the context of avoiding name space collision?

a. To call another constructor in the same class b. To refer to the current object c. To differentiate between instance variables and parameters with the same name d. To import another class

7. Which of the following is the correct signature of the main method in Java?

a. public void main(String[] args) b. public static void main(String[] args) c. public static void main() d. public main(String[] args)

8. Which class is used in Java to take runtime data input from the user?

a. BufferReader b. UserInputStreamReader c. Scanner d. DataInputStreamReader

9. What is the output of the following Java code snippet? (n in output is to be assumed to be the new line character)

a. Hello WorldnNumber: 10 b. Hello WorldNumber: 10 c. Hello nWorldnNumber: 10 d. Hello WorldnNumber: 10n

10. How do you read a line of text from the console using the Scanner class in Java?

a. scanner.readLine() b. scanner.nextLine() c. scanner.getLine() d. scanner.fetchLine()

NPTEL Programming In Java Week 1 Assignment Answers 2023

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

SDM Kaise Bane?

SDM Kaise Bane? SDM कैसे बने जाने योग्यता, सैलरी और आयु सीमा आदि

PM Yashasvi Scholarship Online Apply 2024

PM Yashasvi Scholarship Online Apply 2024 : विद्यार्थियों को सरकार दे रही है 75000 से 125000 तक की स्कॉलरशिप, इस तरह करें आवेदन

Aadhar Card Per Loan Kaise Len

Aadhar Card Per Loan Kaise Len: पाएं घर बैठे आधार कार्ड से 50,000 तक का लॉन

Google Se Paise Kaise Kamaye

Google Se Paise Kaise Kamaye? जाने क्या है ऑनलाइन गूगल पे से पैसे कमाने के तरीके, महीने का 50000 तक कमाएं

Old Note Sale

Old Note Sale: एक झटके में गरीबी मिटा देगा ₹5 का यह पुराना नोट, जान लो खासियत और लाखों में बेचने की जानकारी

Sign in to your account

Username or Email Address

Remember Me

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

NPTEL Assignment Answers and Solutions 2024 (July-Dec). Get Answers of Week 1 2 3 4 5 6 7 8 8 10 11 12 for all courses. This guide offers clear and accurate answers for your all assignments across various NPTEL courses

progiez/nptel-assignment-answers

Folders and files, repository files navigation, nptel assignment answers 2024 with solutions (july-dec), how to use this repo to see nptel assignment answers and solutions 2024.

If you're here to find answers for specific NPTEL courses, follow these steps:

Access the Course Folder:

  • Navigate to the folder of the course you are interested in. Each course has its own folder named accordingly, such as cloud-computing or computer-architecture .

Locate the Weekly Assignment Files:

  • Inside the course folder, you will find files named week-01.md , week-02.md , and so on up to week-12.md . 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. Review these files to find the information you need.

By following these steps, you can easily locate and use the assignment answers and solutions for the NPTEL courses provided in this repository. We hope this resource assists you in your studies!

List of Courses

Here's a list of courses currently available in this repository:

  • Artificial Intelligence Search Methods for Problem Solving
  • Cloud Computing
  • Computer Architecture
  • Cyber Security and Privacy
  • Data Science for Engineers
  • Data Structure and Algorithms Using Java
  • Database Management System
  • Deep Learning for Computer Vision
  • Deep Learning IIT Ropar
  • Digital Circuits
  • Ethical Hacking
  • Introduction to Industry 4.0 and Industrial IoT
  • Introduction to Internet of Things
  • Introduction to Machine Learning IIT KGP
  • Introduction to Machine Learning
  • Introduction to Operating Systems
  • ML and Deep Learning Fundamentals and Applications
  • Problem Solving Through Programming in C
  • Programming DSA Using Python
  • Programming in Java
  • Programming in Modern C
  • Python for Data Science
  • Soft Skill Development
  • Soft Skills
  • Software Engineering
  • Software Testing
  • The Joy of Computation Using Python
  • Theory of Computation

Note: This repository is intended for educational purposes only. Please use the provided answers as a guide to better understand the course material.

📧 Contact Us

For any queries or support, feel free to reach out to us at [email protected] .

🌐 Connect with Progiez

Website

⭐️ Follow Us

Stay updated with our latest content and updates by following us on our social media platforms!

🚀 About Progiez

Progiez is an online educational platform aimed at providing solutions to various online courses offered by NPTEL, Coursera, LinkedIn Learning, and more. Explore our resources for detailed answers and solutions to enhance your learning experience.

Disclaimer: This repository is intended for educational purposes only. All content is provided for reference and should not be submitted as your own work.

Contributors 3

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 2 assignment answers 2023.

NPTEL Programming in Java Week 2 Assignment Answers 2023

Excited for NPTEL’s Java programming week 2 quiz assignment answers?

Look no further! I’ve got you covered with probable answers for all 10 questions. Use these as a helpful guide in completing your assignment with confidence before the deadline.

Table of Contents

NPTEL Programming in Java Week 2 Assignment Answers

Q1. Following is a program given for this question.

What will be the output of the above program?

Answer: a. 22221010

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

Q2. When an array is passed to a method, what value does the method receive?

Answer : a. Reference of the array.

Q3. Following is a program given for this question.

Answer: c. 30

Q4. How many bits are needed for float and double in Java, respectively?

Answer: a. 32 and 64

Q5. Which of the following is a valid automatic type conversion in Java?

Answer: d. int to long

Q6. Consider the following program and identify the output.

Answer: d. Compilation error

Q7. Which of the following is a valid declaration of an object of class say, Student?

Answer: b. Student obj = new Student();

Q8. What is the output of the following program?

Answer: c. 012

Q9. Consider the following piece of code.

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

Answer: d. nptel

Q10. What is the output of the following program?

Programming Answers to Java Assignment

Q1. Complete the code segment to call the method  print()  of class School first  and then call print()  method of class Student .

Disclaimer: These answers are intended only as reference material. No guarantee of accuracy is made. It is strongly recommended to complete the assignment independently.

Also Available:

NPTEL Programming in Java Week 1 Assignment Answers

NPTEL Programming In Java Week 3 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

  • Wednesday, September 25, 2024

NPTEL Programming in Java Week 2 Assignment Solution 2023

Programming-In-Java-Week2-Programming-Assignment-Solutions

NPTEL Programming in Java Week 2 All Programming Assignment Solutions – July 2022 | 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 call the method   print()  of class School first  and then call  print()   method of class Student .

Question : 2 Complete the code segment  to call the method   print()  of class given class Printer to print the following.

——————————–

Question : 3 Complete the code segment to   call print() method of class Question by creating a method named  ‘student()’.

Question : 4 Complete the code segment  to call default constructor first and then any other constructor in the class.

Question : 5 Complete the code segment to  debug / complete the program which is intended to print ‘NPTEL JAVA’.

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: | Coulmn | UID | First_Name | Last_Name | Age | |——–|———|————-|————-|———| | Type | Integer | Varchar(45) | Varchar(45) | Integer | | | | | | |

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

NPTEL Programming In Java Assignment 2 Answers July 2023

NPTEL Programming In Java Assignment 2 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

NPTEL Programming In Java Week 2 Assignment Answers 2023

1. Consider the following code segment: 1 class Question{ 2 public static void main(String args){ 3. System.out.print(“Welcome to NPTEL”); 4. } 5. } Identify the numbers where there is/are error(s) in the above code. a. 1 b. 2 c. 3 d. 4 and 5

2. Consider the following code segment: 1 class Question{ 2 public static void main(String[] param 0{ 3 System.out.print(“Welcome to NPTEL”);)) 4 } 5 } Identify the numbers where there is/are error(s) in the above code. a. 1 b. 2 c. 3 d. 4 and 5

3. Consider the following code segment: 1 class Question{ 2 public static void main(String args[]) { 3. for(int n=1; n<=10; n++){ 4. system.out.print(n+” “); 5. } 6. } 7. } Select the correct output description for the above code. a. Prints first n natural numbers in a single line. b. Prints first n natural numbers, one number in a single line. c. Prints first 10 natural numbers in a single line. d. Prints first 10 natural numbers in a single line with no spaces.

4. Consider the following code segment: 1 class Question{ 2 public static void main(String args[]) { 3. for(int n=1; n<=10; n++){ 4. system.out.print(n+” “); 5. } 6. } 7. } Modify the above code such that it prints all the even numbers till 100. a. Replace line 3 with for (int n=2; n<=100; n++){ b. Replace line 3 with for (int n=2; n<=100; n+=2){ c. Replace line 4 with system.out.print(++n + ” “); d. Both option a and c.

5. Following is a program given for this question.

NPTEL Programming In Java Assignment 2 Answers July 2023

What will be the output of the above program? a. 22221018 b. 22222018 c. 22101018 d. 22221218

6. Consider the following incorrect program. 1 public class Question 2 public static void main (String[] args) { 3. short x = 10; 4. x = x * 5; 5. System.out.print (x); 6. } 7. } How to correct the above code segment? a. Change line 4 as x = (short) (x * 5); b. Change line 4 as x = (short) x * 5; c. Change line 4 as x = (short) x * (short) 5; d. Change line 4 as (short) x = x * 5;

7. What will be the output of the above program?

NPTEL Programming In Java Assignment 2 Answers July 2023

a. 210 b. 120 c. 012 d. 000

8. Consider the following piece of code. public class Question! public static void main (String[] args) { String str = “anpotdelqjpava”; System.out.printin(str.substring (1, 3) +str.substring (4, 5) + str.substring (6, 8)); Which of the following option is the output of the above program? a. java b. nptel java c. nptel java d. nptel

9. What is the output of the following program? public class Main{ public void static main (string args []) { char a = ‘a int b = 20; System.out.printin (a+b); } } a. 60 b. 117 c. 33 d. Compilation error

10. Consider the following program. public class Question public static void main (String[] args) { int x = 5; x *= (2 + 8) ; System.out.printin (x) ; } } What will be the output of the program if it is executed? a. 50 b. 10 c. Compiler error d. 5

NPTEL Programming In Java Week 2 Programming Assignment Answers

1. Complete the code segment to call the method   print()  of class Student first  and then call  print()   method of class School .

2. Complete the code segment  to call the method   print()  of class given class Printer to print the following.

——————————–

Hi! I am class STUDENT

Hi! I class SCHOOL. ——————————–

3. Complete the code segment to call print() method of class Question by creating a method named  ‘studentMethod()’.

4. Complete the code segment  to call default constructor first and then any other constructor in the class.

5. Complete the code segment to  debug / complete the program which is intended to print ‘NPTEL JAVA’.

NPTEL Programming In Java Assignment 2 Answers [July 2022]

1. What is the output of the following program?

2. Which of the following is generate API documentation in HTML format from Java source code? a. javac b. javadoc c. javap d. java

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

NPTEL Programming In Java Assignment 2 Answers July 2023

3. Following is a program given for this question. What will be the output of the above program? a. javanptel b. npteljava c. janjavanptel d. jannpteljava

4. What will happen during the execution of the following code for the command line input? Consider the following input on command line and select the options with the correct output(s). nput: A: “jan java nptel” B: 123 a. A: jannptel javanptel1 nptelnptel b. A:jan java nptel jan java nptel c. B: 11 21 31 d. B: 1231

5. Which of the following is/are TRUE about print) and println) methods? a. print () prints in a single line only and multiple lines cannot be printed in any way. b. print () prints and then appends a line break. c. println () prints in a single line only and multiple lines cannot be printed. d. println () prints and then appends a line break.

6. What was the initial name of Java when it was first developed for embedded systems? a. Greentalk b. Oak c. Java d. Javac

👇 For Week 03 Assignment Answers 👇

7. Which of the following is a valid declaration of an object of class, say Foo? a. Foo obj = new Foo; b. obj = new Foo(); c. Foo obj = new Fool; d. new Foo obj;

8. Following is a program given for this question. What will be the output of the above program? a. 0 b. 1 c. false d. true

9. Which of the following can be used to take input from user during the execution of a program? a. Using the string array provided as a parameter to the main method. b. getText() method can be used to get user input from the command line. c. Scanner class can be used by passing the predefined object System.in d. Once the execution starts, there is no way to provide user input.

10. What is the output of the following program? a 14 b. 12 c. 15 d. 17

Programming Assignment Answers

Q1. Complete the code segment to call the method  print()  of class Student first  and then call print()  method of class School . Code:-

Q2. Complete the code segment  to call the method   print()  of class given class Printer to print the following. Code:-

Q3. Complete the code segment to call print() method of class Question by creating a method named  ‘studentMethod()’. Code:-

Q4. Complete the code segment  to call default constructor first and then any other constructor in the class. Code:-

Q5. Complete the code segment to debug / complete the program which is intended to print ‘NPTEL JAVA’. Code:-

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

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.

Below you can find the answers for NPTEL Programming In Java Assignment 2

NPTEL Programming In Java Assignment 2 Answers [Jan 2022]

Q1. Complete the code segment to call the method  print() of class Student first and then call print() method of class School .

Programming In Java Assignment 1 Answers 2022

Q2. Complete the code segment to call the method  print() of class given class Printer to print the following.

Q3. Complete the code segment to call print() method of class Question by creating a method named ‘studentMethod()’.

Q4. Complete the code segment to call default constructor first and then any other constructor in the class.

Q5. Complete the code segment to debug / complete the program which is intended to print ‘NPTEL JAVA’.

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.

IMAGES

  1. NPTEL PROGRAMMING IN JAVA WEEK 10 PROGRAMMING ASSIGNMENT ANSWERS

    nptel programming in java week 2 assignment answers

  2. NPTEL Programming in Java Assignment 2 Solution 2023

    nptel programming in java week 2 assignment answers

  3. NPTEL Programming in Java Week 11 Assignment Answers 2024 » DBC Itanagar

    nptel programming in java week 2 assignment answers

  4. NPTEL Programming in Java Week 2 Assignment Answers Aug-2023

    nptel programming in java week 2 assignment answers

  5. NPTEL Programming In Java Week 6 Assignment 6 Answers 2024

    nptel programming in java week 2 assignment answers

  6. NPTEL Programming in Java Week 2 Assignment Answers Aug-2023

    nptel programming in java week 2 assignment answers

COMMENTS

  1. Programming in Java NPTEL Assignment Answers of Week 2 (2023)

    Week 2 : Programming Assignment 1. Complete the code segment to call the method print() of class School first and then call print() method of class Student. Answer: ...

  2. Programming in Java Nptel Week 2 Assignment Answers

    These are Programming in Java Nptel Week 2 Assignment Answers All Weeks of Programming In Java: Click Here For answers to additional Nptel courses, please refer to this link: NPTEL Assignment Answers

  3. Programming in Java | NPTEL 2022 | Week 2 Assignments ...

    Programming in Java NPTEL Week 2 Programming Assignment 1 Solutions. Complete the code segment to call the method print() of class Student first and then call print() method of class School. // This is the class named School class School { // This is a method in class School public void print() { System.out.println("Hi! I class SCHOOL.");

  4. NPTEL Programming in Java Week 2 Assignment Answers 2024

    Aug 2, 2024 · NPTEL Programming in Java Week 2 Assignment Answers 2024. 1. Which of the following is the correct way to declare a class in Java? a. public class MyClass {} b. class MyClass[] {} c. public MyClass class {} d. MyClass public class {} Answer :- a

  5. NPTEL Assignment Answers 2024 with Solutions (July-Dec)

    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 ...

  6. NPTEL Programming in Java Week 2 Assignment Answers

    Feb 4, 2023 · Excited for NPTEL’s Java programming week 2 quiz assignment answers? Look no further! I’ve got you covered with probable answers for all 10 questions. Use these as a helpful guide in completing your assignment with confidence before the deadline.

  7. NPTEL Programming in Java Week 2 Assignment Solution 2023

    Feb 8, 2023 · 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 ...

  8. Programming_In_Java_NPTEL | This site is to share the ...

    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’. WEEK 3. Java Week 3:Q1 To the generation of Fibonacci numbers.

  9. NPTEL Programming In Java Assignment 2 Answers July 2023

    Aug 5, 2023 · Answer :- a NPTEL Programming In Java Week 2 Programming Assignment Answers. 1. Complete the code segment to call the method print() of class Student first and then call print() method of class School. Solution:-class School { // This is a method in class School public void print() { System.out.println("Hi! I class SCHOOL.");

  10. Java Week 2:Q1 - NPTEL

    Java Week 2:Q1 Complete the code segment to call the method print() of class Student. ... The due date for submitting this assignment has passed. ... //swayam.gov.in ...