Computer Science, asked by shivushobha79, 7 months ago

Give the output of the function:

class Animal{

void eat()

{

System.out.println(“I am eating”);

}

public static void main()

{

System.out.println(“Tiger”);

Animal obj=new Animal();

obj.eat();

}

}​

Answers

Answered by CoderRishav
2

Answer:

Tiger

I am eating

Explanation:

First tiger will print and then, after it the function is called so I am eating will print.

Answered by anindyaadhikari13
3

Question:-

  • Write the output of the following code.

Steps:-

Given code,

class Animal

{

void eat()

{

System.out.println("I am eating");

}

public static void main()

{

System.out.println("Tiger");

Animal obj=new Animal();

obj.eat();

}

}

The output for the following program is,

Tiger

I am eating.

At first,main method will execute and then objects of Animal class are created and then the 'eat' function is called.

Output:-

Tiger

I am eating

Similar questions