“HAPPINESS SHOULD BE A FUNCTION WITHOUT ANY PARAMETERS”

NPTEL(14 Sep - 04 Dec ) | Week 4 : Quiz Assignment 4 Programming in JAVA Solutions 2020.

 



        Programming in JAVA.       

Assignment 4



Ans: d


1 point

Ans: d



Ans: a


Ans: c/d



Ans: a/b/c


Ans: d



Ans: b



Ans: a


Ans: c



Ans: a/b/d




  WEEK-4 :Programming in JAVA
PLEASE SUBSCRIBE OUR CHANNEL.

FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.

NPTEL (14 Sep - 04 Dec ) | Week 4 : Program 5 Programming in JAVA Solutions 2020.

 



        Programming in JAVA.       




FOR Q3 AND Q4 CODE CLICK HERE 


Java Week 4: Q5

Modify the code segment to print the following output.

-----------------OUTPUT-------------------
Circle: This is Shape1
Circle: This is Shape2
-------------------------------------------------

PROGRAM:


interface ShapeX {
 public String base = "This is Shape1";
 public void display1();
}


interface ShapeY extends ShapeX {
 public String base = "This is Shape2";
 public void display2();
}


class ShapeG implements ShapeY {
 public String base = "This is Shape3";
 public void display1() {
  System.out.println("Circle: " + ShapeX.base);
 }
 
  public void display2(){
  System.out.println("Circle: " + ShapeY.base);
  }
}


  WEEK-4 :Programming in JAVA
<<CLICK HERE FOR  WEEK 4:Quiz Assignment 4>> 
PLEASE SUBSCRIBE OUR CHANNEL.

FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.

NPTEL(14 Sep - 04 Dec ) | Week 4 : Program 3 and Program 4 Programming in JAVA Solutions 2020.

 



        Programming in JAVA.       




Java Week 4: Q3

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

-----------------OUTPUT-------------------
This is large
This is medium
This is small
This is extra-large
-------------------------------------------------

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

PROGRAM:

interface ExtraLarge{
	String extra = "This is extra-large";
	 void display();
}

class Large {
    public void Print() {
        System.out.println("This is large");
    }
}
 
class Medium extends Large {
    public void Print() {
    	  super.Print();  
        System.out.println("This is medium");
    }
}
class Small extends Medium {
    public void Print() {
        super.Print(); ; 
        System.out.println("This is small");
    }
  }

 
class Question43 implements ExtraLarge{
    public static void main(String[] args) {
        Small s = new Small();
        s.Print();
	  Question43 q = new Question43();
	  q.display();
    }
  public void display(){
    
    System.out.print(extra);
    }
    
  }

Java Week 4: Q4

Complete the code segment to call the default method in the interface First and Second.

PROGRAM:

First.super.show();
Second.super.show();

  WEEK-4 :Programming in JAVA
PLEASE SUBSCRIBE OUR CHANNEL.

FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.



NPTEL(14 Sep - 04 Dec ) | Week 4 : Program 1and Program 2 Programming in JAVA Solutions 2020.

 



        Programming in JAVA.       




Java Week 4: Q1

Complete the code segment to execute the following program successfully. You should import the correct package(s) and/or class(s) to complete the code.

PROGRAM:

import java.util.Scanner;
import static java.lang.System.out;

Java Week 4: Q2

Complete the code segment to print the current year. Your code should compile successfully.


PROGRAM:

java.util.Calendar cal =java.util.Calendar.getInstance();

year = cal.get(cal.YEAR);

  WEEK-4 :Programming in JAVA
PLEASE SUBSCRIBE OUR CHANNEL.

FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.



NPTEL (14 Sep - 04 Dec ) | Week 3 : Program 5 Programming in JAVA Solutions 2020.

 



        Programming in JAVA.       




FOR Q3 AND Q4 CODE CLICK HERE 


Java Week 3: Q5

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

PROGRAM:

static int swap(Question t){
 
  int r;
  r=t.e1;
  t.e1=t.e2;
  t.e2=r;
 return 0; 
}

  WEEK-3 :Programming in JAVA
<<CLICK HERE FOR  WEEK 3:Quiz Assignment 3>> 
PLEASE SUBSCRIBE OUR CHANNEL.

FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.

NPTEL(14 Sep - 04 Dec ) | Week 3 : Program 3and Program 4 Programming in JAVA Solutions 2020.

 



        Programming in JAVA.       




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.

PROGRAM:

double height;

Test1(double l,double h){
 super(l);
  height=h;
}

Test1(double l,double b,double h){
 super(l,b);
  height=h;
}

double calculate(){
   double vol;
   vol=length*breadth*height;
  return vol;
}

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

PROGRAM:

QuestionScope qs = new QuestionScope();

System.out.println(qs.sum(n1,n2));
System.out.println(QuestionScope.multiply(n1,n2)); // As Static method can be called without object using class name.
  
}

  WEEK-3 :Programming in JAVA
PLEASE SUBSCRIBE OUR CHANNEL.

FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.



NPTEL(14 Sep - 04 Dec ) | Week 3 : Program 1and Program 2 Programming in JAVA Solutions 2020.

 



        Programming in JAVA.       




Java Week 3: Q1

This program is related to the generation of Fibonacci numbers.

For example: 0, 1, 1, 2, 3, 5, 8, 13,… is a Fibonacci sequence where 13 is the 8thFibonacci number. A partial code is given and you have to complete the code as per the instruction given as comments.

PROGRAM:

if(n==1)
  return 0;
else if(n==2)
  return 1;
  else
  return fib(n-1)+fib(n-2);

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.

PROGRAM:

class Point{
  
 double x,y;
  
   void distance(Point p1,Point p2){
   double diff,xx,yy;
    xx=p2.x-p1.x;
    yy=p2.y-p1.y;
    
    diff=Math.sqrt(xx*xx+yy*yy);      //   sqrt((x2-x2)2  +(y2-y1)2)  simply use distance formula
    System.out.print(diff);
    
  }
  
  
}

  WEEK-3 :Programming in JAVA
PLEASE SUBSCRIBE OUR CHANNEL.

FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.



NPTEL | Week 0: Assignment 3 Question 3 Introduction to Programming in C (14 Sep- 06 Nov) 2020.



        Introduction to Programming in C       



Assignment 3_Question 3:


Write a C program to list all the factorial numbers less than or equal
to an input number n.

A number N is called a factorial number if it is the factorial of a
positive integer. For example, the first few factorial numbers are

   1, 2, 6, 24, 120, ...

*Note* - We do not list the factorial of 0.

Input
-----
A positive integer, say n.

Output
------
All factorial numbers less than or equal to n.
PROGRAM:

#include<stdio.h>

int factorial(int f)
{
  if(f==1)
    return 1;
  else
    return f*factorial(f-1);
  
}

int main()
{

 int n,l=1,g=2;
  
  scanf("%d",&n);
   
  while(n>=l)
  {
    printf("%d ",l);
    l=factorial(g);
    g++;
  };
  
  return 0;
  
}
  
WEEK-0 :INTRODUCTION TO PROGRAMMING IN C

CLICK ON BELOW LINK.
<<CLICK HERE FOR  WEEK 0:ASSIGNMENT 3 QUESTION 2>>

PLEASE SUBSCRIBE OUR CHANNEL.
<CLICK HERE>
FOLLOW OUR WEBSITE FROM THE BUTTON PROVIDED TO THE BOTTOM OF PAGE TO GET SOON ANSWERS OF PROGRAMS.
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100%  correct solutions.