NPTEL Programming In Java Assignment 5 Answers 2022

NPTEL Programming In Java Assignment 5 Answers 2022 :- Here All The Questions and Answers Provided to Help All The Students and NPTEL Candidate as a Reference Purpose, It is Mandetory to Submit Your Weekly Assignment By Your Own Understand Level.

 

Are you looking for the Assignment Answers to NPTEL Programming In Java Assignment 5 Answers 2022? If Yes You are in Our Great Place to Getting Your Solution, This Post Should be help you with the Assignment answer to the National Programme on Technology Enhanced Learning (NPTEL) Course “NPTEL Programming In Java Week 5 Assignment Solution 2022”

 

NPTEL Programming In Java

From My Side : With the expansion of knowledge and Communication Technology, there’s a desire to develop massive and complicated package. Further, those package ought to be platform freelance, web enabled, straightforward to switch, secure, and robust. to satisfy this demand object-oriented paradigm has been developed and supported this paradigm the Java artificial language emerges because the best programming atmosphere. Now, Java artificial language is being employed for mobile programming, web programming, and plenty of alternative applications compatible to distributed systems. This course aims to hide the essential topics of Java programming in order that the participants will improve their skills to address the present demand of IT industries and solve several issues in their own filed of studies.

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.

INTENDED AUDIENCE :  The undergraduate students from the engineering disciplines namely CSE, IT, EE, ECE, etc. might be interested for this course.
PREREQUISITES :  This course requires that the students are familiar with programming language such as C/C++ and data structures, algorithms.
INDUSTRY SUPPORT :   All IT companies.

CRITERIA TO GET A CERTIFICATE

This course can have Associate in Nursing unproctored programming communication conjointly excluding the Proctored communication, please check announcement section for date and time. The programming communication can have a weightage of twenty fifth towards the ultimate score.

Final score = Assignment score + Unproctored programming exam score + Proctored Exam score
  • Assignment score = 25% of average of best 8 assignments out of the total 12 assignments given in the course.
  • ( All assignments in a particular week will be counted towards final scoring – quizzes and programming assignments). 
  • Unproctored programming exam score = 25% of the average scores obtained as part of Unproctored programming exam – out of 100
  • Proctored Exam score =50% of the proctored certification exam score out of 100
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF ASSIGNMENT SCORE >=10/25 AND
UNPROCTORED PROGRAMMING EXAM SCORE >=10/25 AND PROCTORED EXAM SCORE >= 20/50. 
If any one of the 3 criteria is not met, you will not be eligible for the certificate even if the Final score >= 40/100. 

CHECK HERE OTHERS NPTEL ASSIGNMENTS ANSWERS 

BELOW YOU CAN GET YOUR NPTEL Programming In Java Assignment 5 Answers 2022? :

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

1. Consider the following program.

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

a. 100
102

b. 20
22

C. 102
100

d. 22
20

Answer:- A
2. Consider the following program.

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

a. 170
b. 130
c. 0
d. 260

Answer:- A

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

NPTEL Programming In Java Assignment 5 Answers 2022
3. What is the output of the following code?

a. Output: This is Explanation’s Print method
This is Answer’s Print method
b. Error: super.super’ is not allowed.
c. Error: Compilation unsuccessful, as there is only one super class of Answer
d. Output: This is Answer’s Print method
This is Explanation’s Print method

Answer:- B
4. Which of the following is/are interface(s)?

a. DriverManager
b. Connection
c. Statement
d. ResultSet

Answer:- C,B,D
5. Which of the following statement(s) is/are true?

a. You can write a new instance method in the subclass that has the same signature as the one in the superclass, thus overriding it.
b. You can write a new static method in the subclass that has the same signature as the one in the superclass, thus hiding it.
c. A subclass inherits all of the public and protected members of its parent, 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
6. 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 subelass. /
c. You can prevent a class from being sub classed by using the final keyword in the class’s declaration.
d. An abstract class can only be subclassed; it cannot be instantiated.

Answer:- All

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

NPTEL Programming In Java Assignment 5 Answers 2022

7. Consider the following piece of code:

Which of the following statement(s) is/are correct?

a. There is no main () method so the program is not compile successfully.
b. The value of i will be printed as 22, as it is static and final by default.
c. The value of I will be printed as 2. as it is initialized in class B.
d. Compile time error

Answer:- A
8. Which of the following statement(s) is/are true?

a. A class can extend more than one class.
b. An interface can extend many interfaces.
c. An interface can implement many interfaces.
d. A class can extend one class and implement many interfaces.

Answer:- B
9. 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

Answer:- D

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

a. Output: 1020
b. Output : 30
c. Output: 2010
d. Error: Cl is abstract; cannot be instantiated.

Answer:- D

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.

Solution Code : – 

import java.util.Scanner;

interface Number {
int findSqr(int i); // Returns the square of n
}
class A implements Number {
//Define a method to find the square of a number
int i, square;
public int findSqr(int i) {
square=i*i;
return square;
}
}
public class Question5_1{
public static void main (String[] args){
A a = new A(); //Create an object of class A
// Read a number from the keyboard
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
System.out.print(a.findSqr(i));
}
}

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

Solution Code :-

import java.util.Scanner;

interface GCD {
public int findGCD(int n1,int n2);
}
class B implements GCD {
int n1,n2;

//Create a method to calculate GCD
public int findGCD(int n1, int n2){
if(n1==0&& n2==0) {
return -1;
}
else if(n2 == 0){
return n1;
}

else {
return findGCD(n2, n1%n2);
}
}
}
public class Question5_2{
public static void main (String[] args){
B a = new B(); //Create an object of class B
// Read two numbers from the keyboard
Scanner sc = new Scanner(System.in);
int p1 = sc.nextInt();
int p2 = sc.nextInt();
System.out.print(a.findGCD(p1,p2));
}
}

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

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.

Solution Code :-

import java.util.Scanner;

public class Question5_3 {
public static void main(String[] args) {
int a, b;
Scanner input = new Scanner(System.in);

int result;
a = input.nextInt();
b = input.nextInt();

// try block to divide two numbers and display the result
try {
result = a/b;
System.out.println(result);
}
// catch block to catch the ArithmeticException
catch (ArithmeticException e) {
System.out.println(“Exception caught: Division by zero.”);
}

}
}

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.

Solution Code :-

//Prefixed Fixed Code:
import java.util.*;
public class Question5_4{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int length = sc.nextInt();
// create an array to save user input
int[] name = new int[length];
int sum=0;//save the total sum of the array.
try{
for(int i=0;i<length;i++){
int userInput=sc.nextInt();
name[i] = userInput;
sum=sum+name[i];
}
System.out.println(sum);
}
catch(InputMismatchException e) {
System.out.println(“You entered bad data.”);
}
}
}

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

Solution Code :-

import java.util.Scanner;
public class Question5_5{
public static void main (String args[ ] ) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
int j;
try {
switch (i) {
case 0 :
int zero = 0;
j = 92/ zero;
break;
case 1 :
int b[ ] = null;
j = b[0] ;
break;
default:
System.out.println(“No exception”);
}
}
// catch block
catch (Exception e) {
System.out.println(e) ;
}

}
}

Yhaa You have done it but next? if YOU Want to your Others NPTEL Programming In Java Assignment 5 Answers 2022

Related Posts

Leave a Reply

Your email address will not be published.

adplus-dvertising