Day 7
Day 7
DAY 7
1. WAP to show implementation of regular inner classes(how their object is formed
and how to call their method and their outer class method). 2. WAP to show implementation of static inner classes(how their object is formed and how to call their method and their outer class method). 3. WAP to show implementation of method local inner classes(how their object is formed and how to call their method and their outer class method). 4. WAP to show implementation of anonymous inner classes(how their object is formed and how to call their method and their outer class method). 5. Write a class Outer that contains an inner class Inner. The class Outer contains a static method printHello() and a non-static method sayHello(). Invoke these two methods in the non static method speakMsg() and static method broadcast() of Inner class each. Will the code compile successfully? If your code does not compile report the reason for compilation error. 6. A class Employee apart from its usual construct also has an inner class Bill which has following architecture:
String bill_id float bill_amount Public String getDetails() Public void setDetails(String id, float amount)
Write a program to implement how an employee object can be instantiated and thereby for that employee object a bill (object) can be instantiated and manipulated. 7. WAP to show difference between inner class and nested class. 8. WAP to use the variable of a method inside the method local class.
9. WAP to check if inner class is static then its method and variable will show
behaviour like like static or not. 10. WAP of simple regular inner class and perform following operation: a. Accessibility of private variable of outer class, insde the inner class.
b. How to hide the member variable of inner class.
c. Check if super keyword will work inside inner class or not. 11. WAP to check if an inner class can be overridden like a method or not. 12. There is an abstract Student class. BTechStudent class and MCAStudent class extend this Student class. The Student class has a method getAssignment() declaration. The signature of the getAssignment() looks like: Public Assignment getAssignment(); Here Assignment is an interface with following features: Public interface Assignment { Public void createAssignment(String id, String details); Public String getAssignmentId(); Public String getAssignmentDetails(); };l Ought to behaviour as expected by the interface Assignment is that every class that implements Assignment should contain two data members: Assignment Id and Assignment details of java.lang.String type. It is upto the classes (BTechStudent and MCAStudent) to implement assignments their way as per their needs. Implement this system using anonymous inner class.