Skip to content

Commit

Permalink
Add java object oriented proble solution
Browse files Browse the repository at this point in the history
  • Loading branch information
prasadhonrao committed Mar 14, 2022
1 parent 17ccf58 commit db17481
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

class Animal{
void walk()
{
System.out.println("I am walking");
}
}
class Bird extends Animal
{
void fly()
{
System.out.println("I am flying");
}

void sing()
{
System.out.println("I am singing");
}
}

public class Solution{

public static void main(String args[]){

Bird bird = new Bird();
bird.walk();
bird.fly();
bird.sing();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

//Write your code here
class Arithmetic {
public int add(int num1, int num2) {
return num1 + num2;
}
}

class Adder extends Arithmetic {

}

public class Solution{
public static void main(String []args){
// Create a new Adder object
Adder a = new Adder();

// Print the name of the superclass on a new line
System.out.println("My superclass is: " + a.getClass().getSuperclass().getName());

// Print the result of 3 calls to Adder's `add(int,int)` method as 3 space-separated integers:
System.out.print(a.add(10,32) + " " + a.add(10,3) + " " + a.add(10,10) + "\n");
}
}
Empty file.

0 comments on commit db17481

Please sign in to comment.