Question
Option 3 : Compilation fails — C inherits unrelated defaults and must override m() / संकलन विफल — C असंबंधित डिफ़ॉल्ट मेथड इनहेरिट करता है, उसे m() ओवरराइड करना होगा
Detailed Solution
सही उत्तर Compilation fails — C inherits unrelated defaults and must override m() / संकलन विफल — C असंबंधित डिफ़ॉल्ट मेथड इनहेरिट करता है, उसे m() ओवरराइड करना होगा है।
Question:
What happens when the following Java code is compiled? / निम्नलिखित जावा कोड संकलित करने पर क्या होगा? interface I { default void m() { System.out.print("I"); } } interface J { default void m() { System.out.print("J"); } } class C implements I, J { }
Correct Answer: Compilation fails — C inherits unrelated defaults and must override m() / संकलन विफल — C असंबंधित डिफ़ॉल्ट मेथड इनहेरिट करता है, उसे m() ओवरराइड करना होगा
When a class inherits unrelated default methods with the same signature from two interfaces, Java reports a compile-time error unless the class overrides the method. / जब कोई क्लास दो इंटरफेस से समान सिग्नेचर वाले असंबंधित डिफ़ॉल्ट मेथड इनहेरिट करती है, तो जावा कंपाइल-टाइम त्रुटि देता है जब तक क्लास उस मेथड को ओवरराइड न करे।