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 (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 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
- 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
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
I am sharing my journey of studying a course on Programming in Java taught by Prof.Debasis Samanta Sir IIT Kharagpur
omunite215/NPTEL-Programming-in-Java-Ultimate-Guide
Folders and files, repository files navigation, nptel-programming-in-java assignment solutions with explanations and course guide.
This Repository has the ultimate guide to crack the exam of Programming in Java Course taught by Prof.Debasis Samanta Sir from I.I.T(Indian Institute of Technology) Kharagpur
This will also help you practice java., i am sharing all my codes i did during preparation of exam and my learning process., you need to understand these concepts first before solving assignments weekwise:, week-1 => basic concepts., week-2 => methods, functions and encapsulation., week-3 => access specifiers, static scope, info hiding., week-4 => packages and interfaces(basics)., week-5 => interfaces advanced and basics of exception handling., week-6 => multithreading and iostream., week-7 => iostream advanced usage and applet programming(basics)., week-8 => applet programming advance concepts and abstract window toolkit(awt)., week-9 => swing programming and abstract window toolkit(awt)., week-10 => networking with java., week-11 => java database connectivity(jdbc) in detail., week-12 => case studies., course online exam questions:, set-1 unproctored exam ., set-2 unproctored exam ., how to use this repository, this repository is for reference., this repository has all the solutions of nptel weekly assignments. just click on branches and select the week number., each branch has readme file where you will find all the questions., the top most comment is the problem statement to understand the problem and code together., explanation of code has been done through comments wherever neccessary., tips for assignment and exam :-, - every assignment has testcase so your code must need to pass all the testcases to get marks in assignment., - dont write customized print statements because showing your creativity will simply mark zero. i got zero in few assignments not because output was wrong but wrote long print statements before outputs., - prepare basics well before going into exam., reference links to prepare for exam:-.
- NPTEL Swayam
- Geeks for Geeks
Whenever you learn a programming language, you understand about basics of how a software works that makes you think about the beauty of technology. Taking Java or any other programming language will clear your basic concepts of programming which will take you deeper into techonology and help you understand the world of computers.
🏠 Built With:
Specializations:
- UI/UX Design.
- Web Development
🙋♂️ Connect With Me
Programming in Java | NPTEL 2023 | Week 2 quiz solutions
This set of MCQ(multiple choice questions) focuses on the Programming in Java NPTEL 2023 Week 2 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 2 Quiz Solutions” contains 10 questions.
Now, start attempting the quiz.
Programming in Java NPTEL 2022 Week 2 Quiz Solutions
Q1. 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
Q2. Consider the following code segment:
Identify the line number(s) where there is error in the above code.
Answer: d) 4 and 5
Q3. Consider the following code segment:
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.
Answer: c) Prints first 10 natural numbers in a single line.
Q4. Consider the following code segment:
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=1; n<=100; n+=2){ c) Replace line 4 with System.out.print(++n + ” “); d) Both option a and c
Q5. What will be the output of the above program?
a) 22221018 b) 22222018 c) 22101018 d) 22221218
Answer: b) 22222018
Q6. 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;
Q7. What is the output of the following program?
a) 210 b) 120 c) 012 d) 000
Answer: d) 000
Q8. Which of the following option is the output of the above program?
a) java b) npteljava c) nptel java d) nptel
Answer: d) nptel
Q9. What is the output of the following program?
a) 60 b) 117 c) 33 d) Compilation error
Answer: d) Compilation error
Q10. What will be the output of the program if it is executed?
a) 50 b) 10 c) Compiler error d) 5
Answer: a) 50
Programming in Java NPTEL 2023 Week 2 Quiz Solutions
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. 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
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. Which of the following option is the output of the above program?
Q10. What is the output of the following program?
a) 60 b) 3011 c) 33 d) Compilation error
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.
Programming in Java NPTEL 2022 Week 2 quiz Solutions
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 2022 Week 2 Quiz solutions
Q8. Following is a program given for this question.
a) 0 b) 1 c) false d) true
Answer: c) false
Q9. 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.
Answer: c) Scanner class can be used by passing the predefined object System.in
a) 14 b) 12 c) 15 d) 17
Answer: d) 17
<< Pre- Programming in Java Week 1 Assignment Solutions
>> Next- Programming in Java Week 3 Assignment Solutions
Nptel – Deep Learning assignment solutions
Social Networks nptel assignment answers
NPTEL answers: Programming in Modern C++
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).
C programming MCQ : Preprocessor Directives(MULTIPLE CHOICE QUESTION)
C++ mcq : c++ basics(multiple choice question), 2 thoughts on “programming in java | nptel 2023 | week 2 quiz solutions”.
4th answer is b,c and 5th answer is d.
Thanks 🙂 Answers has been updated!
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
IMAGES
VIDEO
COMMENTS
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!
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 ...
Are you looking for Programming in Java NPTEL Week 2 Assignment Answers? You've come to the right place! Access the accurate solutions ... Programming In Java Programming Assignment Solution. Question 1. Complete the code segment to call the method print() of class School first and then call print() method of class Student. ...
Welcome to our detailed walkthrough of the "NPTEL Programming in Java Week 2 Assignment Solution for July 2024," presented by IIT Kharagpur. This video is ta...
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: // Create an object of class Student // Call 'print()' method of class Student // Create an object of class School // Call 'print()' method of class School School school = new School(); Student student = new Student(); school.print ...
Programming Assignments: Dive into hands-on coding exercises that reinforce key concepts covered in the course.Each assignment presents unique challenges to sharpen your Java programming skills. Quizzes: Test your understanding of Java programming with quizzes designed to assess your knowledge and comprehension of course topics.Challenge yourself and track your progress as you advance through ...
In this video, I walk you through the solution to Nptel Week 2 assignment, providing detailed explanations for each question. The answers have been carefully...
NPTEL-Programming-in-Java Assignment Solutions with Explanations and Course Guide This Repository has the ultimate guide to crack the exam of Programming in Java Course taught by Prof.Debasis Samanta Sir from I.I.T(Indian Institute of Technology) Kharagpur
02/07/2020 Programming in Java - Course https://onlinecourses.nptel.ac.in/noc20_cs08/progassignment?name=118 3/3 DOWNLOAD VIDEOS Assignment Solution
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