Hello, I am attempting to write a series of java classes, each of which will be executed from the command line. Each of these classes will have some shared functionality, and I am thinking of using an abstract class to hold this. However, I am doing something that seems to be pretty dumb, and I'm wondering if there is a better ...
This is really weird for me. The following code gets executed. public abstract class AbstractClass { public static void main(String[] args) { System.out.println("Abstract class Excuting"); } } and Actually prints Abstract class Excuting But if I modify the code it works as expected as you can not create an instance of an abstract class. public abstract class AbstractClass { public static ...
we cant use abstract class for creating objects ..because abstract class has atleast one or more abstract methods(method without definition ) but you can extend the abstract class by defining all the abstract methods in that and create the object by using the sub class.. one main thing in this is when you miss to define one or more abstract method ...
try { Class thisClass = Class.forName(className); A newA = (A )thisClass.newInstance(); newA.execute(); } catch (ClassNotFoundException cnfe) { logger.error("Could not find the current class from main!", cnfe); System.exit(255); } catch (InstantiationException ie) { logger.error("Could not lnstantiate the current class from main! " + ie.getMessage(), ie); System.exit(255); } catch (IllegalAccessException iae) { logger.error("Could not lnstantiate the current class from main! " + iae.getMessage(), ...