Skip to content

Commit 8ae7041

Browse files
author
Ram swaroop
committed
constructors: question added
1 parent c197a2c commit 8ae7041

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

_posts/2015-06-30-constructors.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,34 @@ public class Animal {
301301
}
302302
{% endhighlight %}
303303

304-
1. `abc`
305-
2. Empty string
306-
3. Won't compile
307-
4. Runtime error
304+
A. `abc`
305+
B. Empty string
306+
C. Won't compile
307+
D. Runtime error
308+
309+
__Q2.__ What is the result?
310+
311+
{% highlight java linenos %}
312+
class Top {
313+
public Top(String s) {
314+
System.out.print("B");
315+
}
316+
}
317+
318+
public class Bottom2 extends Top {
319+
public Bottom2(String s) {
320+
System.out.print("D");
321+
}
322+
323+
public static void main(String[] args) {
324+
new Bottom2("C");
325+
System.out.println(" ");
326+
}
327+
}
328+
{% endhighlight %}
329+
330+
A. BD
331+
B. DB
332+
C. BDC
333+
D. DBC
334+
E. Compilation fails

0 commit comments

Comments
 (0)