Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
general knowledge
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
beans
 ASP.NET
 :) Hot Jobs
 
 :) Latest Articles


  

 


Deine covariant return type in core java?
Question Posted on 03 Apr 2021

Home >> Java >> Core Java >> Deine covariant return type in core java?




Deine covariant return type in core java?
From java5 now we can override any method by changing return type and if the return type of subclass overriding method is subclass type. And this is known as covariant return type. And covariant return type also specifies that the return type may vary in the same direction as the subclass. Below example will be more clear the covariant return type:-

class baseclass
{
 baseclass get()
  {
    return this;
  }
}

class subclass extends baseclass
{
 subclass get()
  {
    return this;
  }
void message()
{
 System.out.println("welcome to covariant return type");
}

 public static void main(String args[])
 {
  new baseclass().get().message();
 }
}
0
0



 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


Other Important Questions
what is an object
what is OOAD
difference between c++ and java
what is a transient variable in java
difference between C and Java on pointers






 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |