You get a HttpURLConnection
object from a URL
instance that represents an http:
(or https:
) protocol URL, from its openConnection
method. What you get back is a reference to an object conforming to the interface defined by the URLConnection
abstract class (but it'll be an instance of an HttpURLConnection
subclass).
You often don't need to know the concrete class you're working with; you code to an interface that defines the things you should be able to do with what you have. Those things then get done by the concrete class of the object you have a reference to.
Re this specifically:
is there way to user methods of Abstract class without using the class which extends the Abstract Class
Not if they're instance methods, no. The clue is in the name. ;-) To use an instance method, you must have an instance. To have an instance, you must have a concrete (non-abstract) class that the instance is a member of.
But again: Often you don't care what that class is, just that you have an instance conforming to the interface you need to use.