Asked by
Jordan Carty
on Oct 27, 2024Verified
Consider the following class definitions.public class BClass
{
Private int x; public void set(int a)
{
X = a;
} public void print()
{
System.out.print(x) ;
}
}public class DClass extends BClass
{
Private int y; public void set(int a, int b)
{
//Postcondition: x = a; y = b;
}
Public void print() { }
}Which of the following correctly redefines the method print of DClass?(i)
Public void print()
{
System.out.print(x + " " + y) ;
}(ii) public void print()
{
Super.print() ;
System.out.print(" " + y) ;
}
A) Only (i)
B) Only (ii)
C) Both (i) and (ii)
D) None of these
Redefines
To assign a new definition or meaning to an existing term or concept, often in the context of programming or methodologies.
Method Print
A function in programming languages used to output or display data to a standard output device.
- Differentiate between the concepts of method overriding and method overloading.
- Comprehend the notion and application of the super and this keywords.
Verified Answer
KK
Learning Objectives
- Differentiate between the concepts of method overriding and method overloading.
- Comprehend the notion and application of the super and this keywords.