Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What is covariant return type?
What is covariant return type?
✍: Guest
A covariant return type lets you override a superclass method with a return type that subtypes the superclass method's return type. So we can use covariant return types to minimize upcasting and downcasting.
class Parent { Parent foo () { System.out.println ("Parent foo() called"); return this; } } class Child extends Parent { Child foo () { System.out.println ("Child foo() called"); return this; } } class Covariant { public static void main(String[] args) { Child c = new Child(); Child c2 = c.foo(); // c2 is Child Parent c3 = c.foo(); // c3 points to Child } }_break_
406. What is the result of the following statement?
int i = 1, float f = 2.0f;
i += f; //ok, the cast done automatically by the compiler
i = i + f; //error
The compound assignment operators automatically include cast operations in their behaviors.
2013-03-07, 2035👍, 0💬
Popular Posts:
What is the value of this expression? +1-2*3/4 -0.5
How do I use a scriptlet to initialize a newly instantiated bean? A jsp:useBean action may optionall...
How To Export Data to a CSV File? - Oracle DBA FAQ - Introduction to Oracle SQL Developer If you wan...
If we inherit a class do the private variables also get inherited ? Yes, the variables are inherited...
What will be printed as the result of the operation below: main() { char *p1; char *p2; p1=(char *)m...