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
constructors
:
Content language: English
Русский
What will be the result of the program? 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 { B() { System.out.print("B"); a(); } void a() { System.out.print("b"); } }
constructors
Will the following code compile? public class Person { public final String name; int age; }
constructors
What happens if you run this code: class Test { List<Integer> list; Test(){ list = new ArrayList<Integer>(); someVoid(list); } void someVoid(List<Integer> l){ l.add(0); l=null; } public static void main(String[] args) { Test test=new Test(); System.out.println("Size is: "+test.list.size()); } }
constructors
What will be the result of the following code execution? class Super { Super() { System.out.println("Super contructor"); } } public class Main extends Super { Main() { this(1); System.out.println("Main() contructor"); } Main(int i) { System.out.println("Main(int) contructor"); } public static void main(String [] args) { new Main(); } }
constructors
How can a class inheritance be prohibited (top-level classes are considered)?
constructors
Select all the valid signatures of some class Clazz constructors.
constructors
What will happen if you try to compile and run this program? class Box { int b,w; void Box(int b, int w) { this.b = b; this.w = w; } } public class MyBox extends Box { MyBox() { super(10, 15); System.out.println(b + "," + w); } static public void main(String args[]) { MyBox box = new MyBox(); } }
constructors
How much money in the Jack pocket ? public class Main { public static void main(String[] args) { RichJack jack = new RichJack(); jack.showYourWallet(); } } class Jack { Jack() { this.sayHello(); } public void sayHello() { System.out.println("I'm Jack!"); } } class RichJack extends Jack { private int money = 0; public RichJack() { money += 100; }; public void sayHello() { money += 1000000000; // one billion System.out.println("I'm rich Jack!"); } public void showYourWallet() { System.out.println("I have quite some money, about $" + money); }; }
constructors
← Prev
1
2
Next →
Sign Up Now
or
Subscribe for future quizzes