• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

interface

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

why we don't create object of abstract class and interface.....


thanks....
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because interfaces and abstract classes can have unimplemented methods. Their definition says the type in question provides those methods, but if we tried to call them, it wouldn't work.

The whole point of interfaces and abstract classes--the reason the exist--is to define a type that doesn't have a complete implementation and isn't meant to be directly instantiated.
 
Ranch Hand
Posts: 47
MyEclipse IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well ask youself

How can i create an object with incomplete blueprint??


 
Sheriff
Posts: 17086
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Verdegan wrote:The whole point of interfaces and abstract classes--the reason the exist--is to define a type that doesn't have a complete implementation and isn't meant to be directly instantiated.


I don't know if that's really "the whole point" or a consequence(?) -- IMO, the point of defining abstract classes and interfaces is abstraction -- you define a set of behaviors/capabilities without having to worry about the actual implementation; they specify a general contract for behavior or functionality to which all correctly implemented concretions must adhere.
 
Junilu Lacar
Sheriff
Posts: 17086
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Dan wrote:well ask youself

How can i create an object with incomplete blueprint??



I don't think this is quite right either. An abstract class or interface actually is a blueprint of sorts. What's missing is the concrete implementation. Maybe the correct question to ask is something like "Can you actually live in a blueprint?" And the answer is "No, you need the actual house that is built based on the blueprint." Some may argue that I'm quibbling over semantics but programming is very precise and correct semantics are a large part of that.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:

Jeff Verdegan wrote:The whole point of interfaces and abstract classes--the reason the exist--is to define a type that doesn't have a complete implementation and isn't meant to be directly instantiated.


I don't know if that's really "the whole point" or a consequence(?)



Yeah, I guess the incomplete implementation is the whole point and the non-instantiability is a consequence.
 
Ritesh raushan
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
k..but why we create reference variable of interface or abstract class...
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ritesh raushan wrote:k..but why we create reference variable of interface or abstract class...


SearchFirst . so that you will get more information
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ritesh raushan wrote:k..but why we create reference variable of interface or abstract class...



Because, for example, we want a List, but we don't need to know or care if it's a LinkedList or ArrayList.

Or we want a JDBC Connection, but we don't need to know or care if it's a com.oracle.whatever.SomeConnection or a com.mysql.whatever.SomeOtherConnection.

Or we're writing a sort routine that takes a Comparable, but we don't need to know or care if it's an Integer or String or MyStudentClassThatIDefinedForMyJava101Homework. As long as it meets the contract of Comparable, we can sort it.
 
I'm still in control here. LOOK at this tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic