0% found this document useful (0 votes)
2 views4 pages

Corrected Java Codes Updated

The document contains multiple Java classes demonstrating object-oriented programming concepts such as inheritance, interfaces, and abstract classes. Each section includes a main method that creates instances of classes and calls their methods to showcase functionality. The examples illustrate various scenarios like implementing interfaces, overriding methods, and using abstract classes.

Uploaded by

nanisworld11
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Corrected Java Codes Updated

The document contains multiple Java classes demonstrating object-oriented programming concepts such as inheritance, interfaces, and abstract classes. Each section includes a main method that creates instances of classes and calls their methods to showcase functionality. The examples illustrate various scenarios like implementing interfaces, overriding methods, and using abstract classes.

Uploaded by

nanisworld11
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

whyudo3

interface java {
void better();
}

abstract class python implements java {


abstract void good();
}

class lang extends python {


public void better() {
[Link]("This is the Java implementation.");
}

public void good() {


[Link]("This is the Python implementation.");
}
}

public class whyudo3 {


public static void main(String[] args) {
lang d = new lang();
[Link]();
[Link]();

java p = new lang();


[Link]();
}
}

new

class New {
public static void main(String[] args) {
[Link]("This is a simple Java program template.");
}
}

Main2

class Animal {
void makeSound() {
[Link]("Animals make sounds.");
}
}

class Dog extends Animal {


void makeSound() {
[Link]("Dog barks.");
}
}
class Cat extends Animal {
void makeSound() {
[Link]("Cat purrs.");
}
}
public class Main2 {
public static void main(String[] args) {
Animal jugal;
Animal a = new Dog();
Animal b = new Cat();

[Link]();
[Link]();

jugal = new Dog();


[Link]();

jugal = new Cat();


[Link]();
}
}

whyudo2

interface Dal {
void eating();
}

interface Curry extends Dal {


void along();
}

abstract class meal {


abstract void serving();
}

class lunch extends meal implements Curry {


public void serving() {
[Link]("Lunch is being served.");
}

public void eating() {


[Link]("Eating Dal.");
}

public void along() {


[Link]("Eating with Curry.");
}
}

public class whyudo2 {


public static void main(String[] args) {
lunch d = new lunch();
[Link]();
[Link]();
[Link]();
}
}

mywish

abstract class Jungly {


abstract void shutup();
}

class smtg extends Jungly {


void shutup() {
[Link]("Executing shutup() method.");
}
}

public class mywish {


public static void main(String[] args) {
smtg n = new smtg();
[Link]();
Jungly m = new smtg();
[Link]();
[Link]("Program execution completed.");
}
}
whyudo4
class cbit {
void orientation() {
[Link]("Orientation session at CBIT is scheduled.");
}
}

abstract class mgit extends cbit {


abstract void orientationn();
}

class whatever extends mgit {


public void orientationn() {
[Link]("Orientation details for MGIT are not available.");
}
}

public class whyudo4 {


public static void main(String[] args) {
whatever w = new whatever();
[Link]();
[Link]();
}
}

Main1
abstract class Animal {
abstract void makeSound();
void sleep() {
[Link]("Generic animal is sleeping.");
}
}
class Dog extends Animal {
void makeSound() {
[Link]("Dog makes a sound: Bark!");
}
@Override
void sleep() {
[Link]("Dog is sleeping in the lab.");
}
}
public class Main1 {
public static void main(String[] args) {
Animal myDog = new Dog();
[Link]();
[Link]();
}
}

whyudo

interface Rice {
void eating();
}

interface Curry extends Rice {


void drinking();
}

class dinner implements Curry {


public void eating() {
[Link]("Eating rice.");
}
public void drinking() {
[Link]("Having curry after rice.");
}
}

class whyudo {
public static void main(String[] args) {
dinner d = new dinner();
[Link]();
[Link]();
[Link]("Enjoying rice with curry.");
}
}

You might also like