Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
override
:
Content language: English
Русский
What will be the result of the compilation and execution of the following code? 01. class A { 02. public void process() { System.out.print("A,"); } 03. } 04. public class B extends A { 05. public void process() throws IOException { 06. super.process(); 07. System.out.print("B,"); 08. throw new IOException(); 09. } 10. 11. public static void main(String[] args) { 12. try { new B().process(); } 13. catch (IOException e) { System.out.println("Exception"); } 14. } 15. }
Override
Is it possible to overload operators in Java?
Override
Given the following code public class OverrideThrowsTest { public static void main(String[] args) // 1 { A a = new A(); a.method(); A ab = new B(); ab.method(); B b = new B(); b.method(); } } class A { public void method() throws IOException {} } class B extends A { public void method() throws FileNotFoundException {} } Select all the answers, for which, if placed into line 1, code will compile.
Override
What happens after the following code is compiled/executed? 1.import static java.lang.System.*; 2.public class A { 3. public static void main(String[] args){ 4. B b1 = new B("one","two"); 5. B b2 = new B("one", "two"); 6. B b3 = b1; 7. out.println(b1 == b2); 8. out.println(b1 == b3); 9. out.println(b2 == b3); 10. out.println(b1.equals(b2)); 11. out.println(b1.equals(b3)); 12. out.println(b3.equals(b2)); 13. } 14.} class B { public B(String prop1, String prop2){ this.prop1 = prop1; this.prop2 = prop2; } String prop1 = null; String prop2 = null; }
Override
What will be printed to console as a result of the following code execution? public class Test { public static void main(String[] s) { A a = new B(); a.b(); } } class A { void a() { System.out.println("A-a"); } void b() { System.out.println("A-b"); a(); } } class B extends A { void a() { System.out.println("B-a"); } void b() { System.out.println("B-b"); super.b(); } }
Override
What will be the following program's output? package tutorial.base; public class TypesTutorial { public static void main(String... args) { A alpha = new B(); } } class A { A() { System.out.print("A"); a(); } void a() { System.out.print("a"); } } class B extends A { B() { System.out.print("B"); a(); } void a() { System.out.print("b"); } }
Override
What is the result of the following code compilation and execution? public class Test extends A { public int i = 1; public static void main(String... args) { System.out.print(new Test().i); System.out.print(new A().i); System.out.print( ((A)new Test()).i ); } } class A { public int i = 2; }
Override
What will be the result of the following code execution? class A { public void process() { System.out.print("A "); } } class B extends A { public void process() throws RuntimeException { super.process(); if (true) throw new RuntimeException(); System.out.print("B "); } public static void main(String[] args) { try { ((A)new B()).process(); } catch (Exception e) { System.out.print("Exception "); } } }
Override
What is the result of the following code fulfillment: class A { public void m(int k) { System.out.println("class A, method m : " + ++k); } } class B extends A { public int m(int k) { System.out.println("class B, method m : " + k++); return k; } } public class MainClass { public static void main(String args[]) { A a = new B(); a.m(34); } }
Override
What will be the result of a: class Clidders { public final void flipper() { System.out.println("Flip a Clidder"); } } public class Clidlets extends Clidders { public void flipper() { System.out.println("Flip a Clidlet"); super.flipper(); } public static void main(String [] args) { new Clidlets().flipper(); } }
Override
← Prev
1
2
Next →
Sign Up Now
or
Subscribe for future quizzes