“HAPPINESS SHOULD BE A FUNCTION WITHOUT ANY PARAMETERS”

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.



No comments:

Post a comment

If you have any problems related to solutions or any concept please let me know.