Java Programming and Technical Programming Basics

6. Which of the following refers to data encapsulation in object oriented programming?

A. The data and operations for an object are defined and fixed

B. The data of an object is encapsulated in its class

C. The data is hidden for an object

D.A class can have multiple object​

Read Solution (Total 2)

Java Other Question

class Mammal
{
String name= "Dog";
String makeNoise()
{
return "Bow Wow";
}
}

class Cat extends Mammal
{
String name="Cat";
String makeNoise()
{
return "Meow";
}
}

public class Main
{
void go()
{
Mammal m = new Cat();
System.out.println(m.name + m.makeNoise());
}
public static void main (String[] args)
{
new Main().go();
}
}

What is the output of the above program?

A. CatMeow
B. DogBow Wow
C. DogMeow
D. CatBow Wow