Powered by Blogger.

The

Two matrices and print the product for the same.


INPUT

public class Matrix1{
public static void main(String args[]){   
int a[][]={{1,1,1},{2,2,2},{3,3,3}}; 
int b[][]={{1,1,1},{2,2,2},{3,3,3}};     
int c[][]=new int[3][3];   
for(int i=0;i<3;i++){ 
for(int j=0;j<3;j++){ 
c[i][j]=0;   
for(int k=0;k<3;k++)   
{   
c[i][j]+=a[i][k]*b[k][j];   
}
System.out.print(c[i][j]+" "); 
}
System.out.println(); 
} 
}}

OUTPUT



Share
Tweet
Pin
Share
No Comments

Add two matrices and print the resultant matrix.


INPUT

public class Matrix{
public static void main(String args[]){ 
int a[][]={{1,3,4},{2,4,3},{3,4,5}}; 
int b[][]={{1,3,4},{2,4,3},{1,2,4}};   
int c[][]=new int[3][3];   
for(int i=0;i<3;i++){ 
for(int j=0;j<3;j++){ 
c[i][j]=a[i][j]+b[i][j]; 
System.out.print(c[i][j]+" "); 
} 
System.out.println(); 
} 
}}

OUTPUT



Share
Tweet
Pin
Share
No Comments
Multiple Inheritance.


INPUT

interface Car
{
    int speed=60;
    public void distanceTravelled();
}
interface Bus
{
    int distance=100;
    public void speed();
}
public class Vehicle implements Car,Bus
{
    int distanceTravelled;
    int averageSpeed;
    public void distanceTravelled()
    {
        distanceTravelled=speed*distance;
        System.out.println("Total Distance Travelled is : "+distanceTravelled);
    }
    public void speed()
    {
        int averageSpeed=distanceTravelled/speed;
        System.out.println("Average Speed maintained is : "+averageSpeed);
    }
    public static void main(String args[])
    {
        Vehicle v1=new Vehicle();
        v1.distanceTravelled();
        v1.speed();
    }
}

OUTPUT



Share
Tweet
Pin
Share
No Comments
Method Overriding



INPUT

class Human{
 
   public void eat()
   {
      System.out.println("Human is eating");
   }
}
class Boy extends Human{
 
   public void eat(){
      System.out.println("Boy is eating");
   }
   public static void main( String args[]) {
      Boy obj = new Boy();
   
      obj.eat();
   }
}

OUTPUT



Share
Tweet
Pin
Share
No Comments
Single Level Inheritance. 


INPUT

class Single{
 static int num1=10;
 static int num2=5;
}

class Main extends Single{
 public static void main(String[] args){
 int num3=2;
 int result=num1+num2+num3;
 System.out.println("Result of child class is "+result);
 }
}

OUTPUT



Share
Tweet
Pin
Share
No Comments
Implementation of Abstract Class.



INPUT

import java.util.Scanner;
abstract class test
{
abstract void get();
}
class test1 extends test
{
void get()
{
int a,b;
Scanner ob=new Scanner(System.in);
System.out.print("Enter 1st Number: ");
a=ob.nextInt();
System.out.println("Enter 2st Number: ");
b=ob.nextInt();
System.out.println("Addition is: "+(a+b));
}
}
class prac4C
{
public static void main(String args[])
{
test1 obj=new test1();
obj.get();
}
}

OUTPUT



Share
Tweet
Pin
Share
No Comments
Constructor And Destructor.


INPUT

class Square{
int width,height;
Square( int a , int b){
width = a;
height = b;
}
int area(){
return width * height;
}
}
class Cal{
public static void main(String[] args){
{
Square s1 = new Square(10,20);
int area_of_sqaure = s1.area();
System.out.println("The area of square is:" + area_of_sqaure);
}
}
}

OUTPUT



Share
Tweet
Pin
Share
No Comments
The Method asec() And desc().



INPUT

import java.util.*;
class prac4A
{
Scanner input=new Scanner(System.in);
int num,i;
int arr[];
int temp=0;
public void getdata()
{
System.out.print("Enter the size of array: ");
num=input.nextInt();
arr=new int[num];
System.out.print("Enter the number: ");
for( i=0;i<num;i++)
{
arr[i]=input.nextInt();
}
}
void putdata()
{
System.out.print("Given numbers are: ");
for(i=0;i<num;i++)
{
System.out.println(arr[i]);
}
}
void asce()
{
for(i=0;i<num;i++)
{
for(int j=i+1;j<num;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.print("Ascending order of number are: ");
for(int i=0;i<num;i++)
{
System.out.println(arr[i]);
}
}
void desc()
{
for(i=0;i<num;i++)
{
for(int j=i+1;j<num;j++)
{
if(arr[i]<arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.print("Descending order of number are: ");
for(int i=0;i<num;i++)
{
System.out.println(arr[i]);
}
}
public static void main(String args[])
{
prac4A ob=new prac4A();
ob.getdata();
ob.putdata();
ob.asce();
ob.desc();
}
}

OUTPUT



Share
Tweet
Pin
Share
No Comments

About me

Labels

  • C Programming
  • Java Programming
  • Python Programming
  • Software Engineering

recent posts

Sponsor

Facebook

Blog Archive

  • ▼  2020 (39)
    • ▼  April (11)
      • Software Engineering - Agile Model | VCMIT
      • Software Engineering - Incremental Model | VCMIT
      • Software Engineering - Spiral Model | VCMIT
      • Software Engineering - RAD (Rapid Application Deve...
      • Software Engineering - Waterfall Model | VCMIT
      • Software Requirements In Software Engineering | VCMIT
      • Why Software Engineering is Popular? | VCMIT
      • What is Software Engineering? | VCMIT
      • A Brief History Of Software | VCMIT
      • Types Of Software | VCMIT
      • What Is Software? | VCMIT
    • ►  March (28)

Popular Posts

  • Types Of Software | VCMIT
    Types Of Softwares The two main types of software are system software and application software. System software is a type of computer progra...
  • A Brief History Of Software | VCMIT
    History Of Software The Early Days of Software Computer scientist Tom Kilburn is responsible for writing the world’s very first piece of sof...
  • Software Engineering - RAD (Rapid Application Development) Model | VCMIT
    RAD (Rapid Application Development) Model RAD is a linear sequential software development process model that emphasizes a concise developmen...
  • Python Turtle Python Logo Program | Turtle | VCMIT
    Turtle Python Logo Program INPUT import turtle l1 = [[0.0, -238.0], [92.6, -219.3], [168.3, -168.3], [219.3, -92.6], [238.0, 0.0], [219.3, 9...
  • Applications Of C Programming | Audience & Prerequisites | VCMIT
    Applications of C Programming C was initially used for system development work, particularly the programs that make-up the operating system....
  • Write A Program To Implement Liang - Barsky Line Clipping Algorithm | VCMIT
    Write A Program To Implement Liang - Barsky Line Clipping Algorithm INPUT #include<stdio.h> #include<graphics.h> #include<mat...
  • Why Software Engineering is Popular? | VCMIT
    Why Software Engineering is Popular? Here are important reasons behind the popularity of software engineering: Large software – In our real...
  • What is Software Engineering? | VCMIT
    What is Software Engineering? Software engineering is defined as a process of analyzing user requirements and then designing, building, and ...
  • Software Requirements In Software Engineering | VCMIT
    Software Requirements The software requirements are description of features and functionalities of the target system. Requirements convey th...
  • Draw The Walking Man On The Screen Program In C | BGI | VCMIT
    Draw The Walking Man On The Screen Program In C INPUT #include<stdio.h> #include<graphics.h> #define ScreenWidth getmaxx() #defi...

Created with by ThemeXpose | Copy Blogger Themes