05-02-25 ---------- Q)What is wrong with the following code? class Vehicle{ abstract void move(); } class Car extends Vehicle{ } Ans:- Vehicle class must be made abstract as it contains an abstract method. Q)What is wrong with the following code? abstract class Vehicle{ abstract void move(); } class Car extends Vehicle{ } Ans:- Whenever a class is inheriting from an abstract class,it is the duty of the child class to override all the abstract methods of the parent class. Q)What is wrong with the following code? abstract class Vehicle{ abstract void move(); } abstract class Car extends Vehicle{ } Ans:-Nothing wrong. Q)What is method overloading? =>A class having more than one method with same name but with different parameters is nothing but method overloading. =>Parameters are said to be different if they differ atleast in one of the following criteria. 1)no. of parameters 2)type of parameters 3)order of parameters Q)Example program on method overloading. //MethodOverloading.java class Item{ int code; String title; float price; void giveDataToItem(int code,String title,float price){ this.code=code; this.title=title; this.price=price; } void giveDataToItem(float price){ this.price=price; } void displayItemData(){ System.out.println("Item code:"+code); System.out.println("Item title:"+title); System.out.println("Item price:"+price); } } class MethodOverloading{ public static void main(String args[]){ Item item=new Item(); item.giveDataToItem(101,"CD",500); System.out.println("Item details...."); item.displayItemData(); item.giveDataToItem(20); System.out.println("After modification, Item details...."); item.displayItemData(); } }