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
Русский
Why annotation @Override is needed when you redefine (or realize) methods?
Override
What will be the result of the launch of this code? package tutorial.base; public class TypesTutorial { public static void main(String... args) { A alpha = new B(0); } } class A { A(int x){ // - 1 - a(x); // - 2 - } void a(int x) { System.out.println("A-a: " + x); } } class B extends A { B(int x) { // - 3 - a(x); // - 4 - } void a(int x) { System.out.println("B-a: " + x); } }
Override
What will be displayed? class A { int x = 1; public void printX() { System.out.println(getX()); } public int getX() { return x; } } class B extends A { int x = 2; public int getX() { return x + 1; } } public class Test { public static void main(String[] args) { A classA = new B(); classA.printX(); } }
Override
What happens during compiling and executing the code: public class GoTest { public static void main(String[] args) { Sente a = new Sente(); a.go(); Goban b = new Goban(); b.go(); Stone c = new Stone(); c.go(); } } class Sente implements Go { public void go() { System.out.println("go in Sente"); } } class Goban extends Sente { public void go() { System.out.println("go in Goban"); } } class Stone extends Goban implements Go { } interface Go { public void go(); }
Override
What will be the result when the following code is compiled and executed? final public class Parent { final public void test() { System.out.println("hello"); } } class Child extends Parent { //1 public void test() { //2 System.out.println("world"); } } class Main { public static void main(String args[]) { Child c = new Child(); c.test(); } }
Override
What will be printed out as a result of the following code execution? public class Main { private static class A1 { private String test() { return "A1"; } } public static class A2 extends A1 { public String test() { return "A2"; } } public static class A3 extends A2 { public String test() { return "A3"; } } public static void main(String ... arg) { A1 a1 = new A1(); System.out.println(a1.test()); a1 = new A2(); System.out.println(a1.test()); a1 = new A3(); System.out.println(a1.test()); } }
Override
Which lines lead to compilation errors? abstract class Shape { def perimeter: Int def area: Int } class Rectangle(width: Int, height: Int) extends Shape { def perimeter = 2 * (width + height) // 1 override def area = width * height // 2 } class Square(width: Int) extends Rectangle(width, width) { def perimeter = 4 * width // 3 override def area = width * width // 4 }
override
Select all correct ways to extend following traits. trait QuizfulOne { var value: String } trait QuizfulTwo { def value: String }
override
Declaring abstract "var" members
override
← Prev
1
2
Next →
Sign Up Now
or
Subscribe for future quizzes