Monday 25 January 2021

Java Program to implement an interface structure

 Code : 

interface I1

{

  public void comppute1();

}


interface I2 extends I1

{

  public void compute2();

}


Output : 



Java Program to implement the concept of interface

 Code :

interface I1

{

  void compute1();

}

    class B implements I1

    {

      public void compute1()

      {

        System.out.println("Computed Output");

      }

     }

class Main

{

  public static void main()

  {

    B B1 = new B();

    B1.compute1();

  }

}

Output :  

   



Wednesday 13 January 2021

CPP Program to implement function overloading.

 Code :

#include<iostream>

using namespace std;

int volume(int);

double volume(double,int);

long volume(long,int,int);

int main()

{

cout<< volume(10)<<endl;

cout<< volume(2.5,8)<<endl;

cout<< volume(100,75,15)<<endl;

return 0;

}

int volume(int s)

{

return(s*s*s);

}


double volume(double r,int h)

{

return(3.14519*r*r*h);

}


long volume(long l,int b,int h)

{

return(l*b*h);

}


Output :







Sunday 10 January 2021

A simple Java program with multiple statements

 Code :


class SquareRoot

{

  public static void main(String args[])

  {

    double x = 5;                 // Declaration and initialization

      double y;                     // Simple declaration

      y = Math.sqrt(x);

      System.out.println("y = " + y);

  }

}


Output : 




A simple Java program to print Hello World

 Code :

class SampleOne

{

  public static void main(String args[])

  {

    System.out.println("Hello World");

  }

}


Output :