Ravi Tutorials Provide Project Training

JAVA ASSIGNMENT-2


Programs Assignment 2  – 2018

Programs Assignment – 2

1. Write a Java program to show that private member of a super class cannot be accessed from derived classes.
2. Write a program which show the calling sequence of default constructorin multilevel inheritance.
3. Create a class Student and derive class Result. Student class has name and rollNo. Result class has sub1, sub2, sub3 and total_marks. Student class and Result class has their own display method to display their parameters. Display the result of 5 students. Take input using parameterized constructors. Use super keyword to call parent class constructor and parent class method.
4. Write a class Worker and derive classes DailyWorker and SalariedWorker from it. Every worker has a name and a salary rate. Write method ComPay (int hours) to compute the week pay of every worker. A Daily Worker is paid on the basis of the number of days s/he works. The Salaried Worker gets paid the wage for 40 hours a week no matter what the actual hours are. Test this program to calculate the pay of workers. You are expected to use the concept of polymorphism to write this program.
5. Write a program which show the Dynamic method dispatch.
6. Create abstract class Figure and its child classes Rectangle and Triangle. Figure class has abstract area method which is implemented by Rectangle and Triangle class to calculate area. Use run time polymorphism to calculate area or Rectangle and Triangle objects.
7. Write a program which show the Dynamic method dispatch using interface.
8. Write a program in Java to show the usefulness of Interfaces as a place to keep constant value of the program.
9. Create an Interface having two methods division and modules. Create a class, which overrides these methods.
10. Write a program in Java which show that interface can inherit another interface. Take interface A which have input method and another interface B which have display method. Create one child class C which implements the both methods.
11. Write a program which show partial implementation concept in interface.
12. Write a program to accept names from the user, print all the names which have the surname “Patel” in it.
13. Write a java application which accept two strings. Merge both the string using alternate characters
Of each strings.
      Eg. “Hello” and “Good”.
     Result should be, “HGeololdo”.
14. Write a java code which accept a string and display the string in reverse order.
15. Write a program in Java to create a String object. Initialize this object with your full name. Find the length of your name using the appropriate String method. Findwhether the character ‘a’ is in your name or not; if yes find the number of times ‘a’ appears in your name. Print locations of occurrences of ‘a’ .
16. Write a program in Java for String handling which performs the following using StringBuffer class:
i) Checks the capacity of StringBuffer objects.
ii) Reverses the contents of a string given on console and converts the resultant string in upper case.
iii) Reads a string from console and appends it to the resultant string of ii.
17. Write a program for searching a given sub string from the given sentence. Also calculate number of times given sub string occur in given sentence.
18. Write a program to make a package Balance in which has Account class with Display_Balance method in it. Import Balance package in another program to access Display_Balance method of Account class.
19. Write a program which show the different package non sub class concept. Check the result of different access specifiers – private, public, protected and default.
20. Write a program which show the different package sub class concept. Check the result of different access specifiers -– private, public, protected and default.