NPTEL Programming In Java Assignment 7 Answers 2022

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

What is Programming In Java?

With the growth of Information and Communication Technology, there is a need to develop large and complex software. Further, that 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, the Java programming language is being used for mobile programming, Internet programming, and many other applications compatible with 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 field of studies.

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of the 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 7

NPTEL Programming In Java Assignment 7 Answers 2022 {July – Dec}

1. Which of these is method for testing whether the specified element is a file or a directory?

a. IsFile()
b. isFile()
c. Isfile()
d. isfile()

Answer:- b

2. Which of the following is/are NOT Standard Stream(s)?

a. System.in
b. System.out
c. System.er
d. System.console

Answer:- d

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

NPTEL Programming In Java Assignment 7 Answers 2022

3. What will be the output of the Java code?

a. NPTEL
b. NPTELJULY/2022
c. NPTELJULY/2022
d. 2022

Answer:- d

4. What will be the output if the above program is executed?

a. It will give compile-time error
b. It will give run-time error
C. j
d. 106

Answer:- d

5. Which method is used to write a byte to the current output stream?

a. public void write(int b)throwvs IOException
b. public void write(bytel ] b}throws IOException
C. public vo1d flush(Othrows loException
d. public void close( )throws lOException

Answer:- b

6. Which method of RandomAccessFile clas reads a line from the file and returns it as a String ?

a. Writelnt().
b. readLine()
C. readnt()
d. WriteDouble()

Answer:- b

👇For Week 08 Assignment Answers👇

NPTEL Programming In Java Assignment 7 Answers 2022

7. Which of these class is not a member clas of java.io package?

a. File
b. PrintStream
c. StringReader
d. Stream

Answer:- d

8. Which of the followving is/are interface(S) of java.io package?

a. FileReader
b. FileWriter
c. DataOutput
d. Datalnput

Answer:- c, d

9. In which Java APIs the classes for handling all IO-streams are defined?

a. java.lang
b. java.util
C. java.i0
d. java.awt

Answer:- c

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

a. length: 6
b. length: 5
c. length: 0
d. length:1

Answer:- b 

For More NPTEL Answers:- CLICK HERE

Join Our Telegram:- CLICK HERE

NPTEL Programming In Java Assignment 7 Answers 2022:-

MCQ ASSIGNMENT WEEK 7 ANSWERS CLICK HERE

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.

Code:-

import java.util.*;
        public class Question1{ 
        public static void main (String[] args){ 
	        
             int i,number=0,sum=0;
             Scanner sc = new Scanner(System.in);
		for (i=0;i<3;i++)
		{
		    number = sc.nextInt();
		    
  		    sum =sum+number;
          
        }

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

Code:-

try {  
     InputStreamReader y=new InputStreamReader(System.in);  
     BufferedReader b=new BufferedReader(y);  
     String number=b.readLine();  
     int n = Integer.parseInt(number);
     System.out.println(n*n);
    }
   catch (Exception e)
   {
       System.out.println("Please enter valid data");
    }

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.

Code:-

String s = new String(barr,n,1);  
System.out.println(barr[n]);
System.out.println(s); 
}

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

Code:-

for(int a=0;a<s1.length();a++)
     {  
          char str=s1.charAt(a);
          if(str=='e' || str=='E'|| str=='a' || str=='A' || str=='i' || str=='I' || str=='o' || str=='O' || str=='u' || str=='U') 
	     {
	       c=c+1;
         }  
     } 

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.

Code:-

   byte[] b=s1.getBytes();   
	      
                byte B = (byte) c;
            	b[n]=B;
		System.out.println(new String(b)); 
	   }

👇FOR NEXT WEEK ASSIGNMENT ANSWERS👇

NPTEL Programming In Java Assignment 7 Answers 2022

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