void changeCadence(int newValue);
void changeGear(int newValue);
void speedUp(int increment);
void applyBrakes(int decrement);
To implement this interface, the name of your class would change (to
ACMEBicycle, forexample), and you'd use the implementskeyword in the class declaration:class ACMEBicycle
// remainder of this class implemented as before
we can create a class by extending from more than one class. It is problematic. So in Java thisfeature is eliminated. Anyway for getting multiple inheritance, Java introduced the concept ofinterfaces. So we can create a class by extending one class or we can implement any number ofinterfaces for it. But the restriction is we have to implement / descr
ibe every method existing inthe interfaces
What is a Constructor ?Explain the need of constructors overloading in Java
The constructor method is called when a new instance of an object is created. Constructors
and methods differ i
n three aspects of the signature: modifiers, return type, and name. Like
can have any of the access modifiers: public, protected, private, or none
Unlike methods, constructors can take only access modifiers.Therefore, constructors cannot be abstract
Overloading is a powerful feature, but you should use it only as needed. Use it when you actuallydo need multiple methods with different parameters, but the met
hods do the same thing
a) What is an exception? Explain different types of exceptions in Java.
Also explainhow an exception subclass are created, in Java.
xceptions are the customary way in Java to indicate to a calling method
that an abnormal
condition has occurred.When a method encounters an abnormal condition (an
) that it can't handle itself, it may
an exception. Throwing an exception is likethrowing a beeping, flashing red ball to indicate there is a problem that can't be handled where itoccurred. Exceptions are
by handlers positioned along the thread's method invocationstack.
Exceptions are 2 types.
All the exception for that compiler doesn't care are comes under unch
ecked exception i.e.ArithmaticException, ArrayIndexOutofBoundexp etc