Why is ClassLoader an abstract class? [closed] - java

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
ClassLoader is an abstract class, even though it doesn't have any abstract methods. Why is that so? Are there any other abstract classes without abstract methods?

A class with abstract methods has to be abstract. However, an abstract class doesn't have to have abstract methods.
Generally, a class should be abstract whenever it doesn't make sense conceptually for instances of that class to exist. Having incomplete implementation is one example of this (and it happens to be enforced by the compiler), but it's not the only example.

Related

Load and start a Java class dynamically [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Class<? extends Runnable> theClass =
Class.forName("C:\Myclass.class").asSubclass(Runnable.class);
Runnable instance = theClass.newInstance();
new Thread(instance).start();
I want to write like this C:\\Myclass.class
Class.forName() takes a class name such as java.lang.Thread as parameter, not a file path. You have to load your class by using a dynamic ClassLoader
See: Method to dynamically load java class files
You have an error in your Class.forName().
You have to supply the fully qualified class name (FQCN) to this method.
If you want to load a certain class from an external source you have to write your own ClassLoader.

Work of Serializable in Java [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
When serializable is a marker interface, how could it make the object persistent?
When the body of the interface is nothing how it it perform some action on the class that implements it?
Using ObjectOutputStream makes the object persistable. This class will only serialise classes marked with this interface to prevent you serialising classes which you didn't intend or cannot be serialised.
Note: Some serialisation libraries do not follow all the rules of Serialzation and can ignore the Serializable interface.

is Polymorphism also applies in Abstract Classes? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
A common argument is that Polymorphism only applies to interfaces and not abstract classes.
Is the relationship of as Abstract parent class to a concrete class that extends it considered a polymorphism?
List list = new Arraylist()// Polymorphism as List is an interface
AbstractClass parent = new Child(); // Is this also considered polymorphic?
Common argument is Polymorphism only applies to Code to interface and Not abstract classes.
That "argument" is factually incorrect.
Polymorphism works just fine in Java whether you are using interfaces, abstract classes or non-abstract classes. (There are questions about which is best for long term maintainability, but that is a different topic.)
I'd be curious where you found that "argument". Can you provide a URL?
Yes. That is polymorphic.......

can I have an abstract class inheriting from another abstract class ? (java) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
public abstract class Two extends One
{
}
Class One is defined as
public abstract class One
{
}
Yes, and you cannot instantiate it either, of course.
Yes, you can.
If you extend a class with an abstract class and do not define or provide the implementation for the base class abstract methods then the child class extending it would automatically become abstract.

Java 7 Objects class [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
There is a public final class Objects in Java 7 that extendes the java.lang.Object base class.
Will this by default be the base class like or do we need to call the method on "Objects" class and call the corresponding methods?
No. Nothing changes. The Objects class is simply an utility class. It has only static methods, it's in the util package, and does what ObjectUtils from commons-lang is doing.
Objects is final and it extends Object giving you null safe utilities.

Categories