1. Write a
program to define a class Employee with attributes name, employee_id and salary
and also provide a parameterized constructor to initialize all the attributes.
Create an appropriate collection to store the Employee
objects such that the non-duplicate objects are stored in descending order of
their salary. Use Iterator to display the names and salary of all the
employees.
2. WAP to
create a class Student with attributes name and cgpa. Add at least 5 Student
objects in an appropriate collection such that they are sorted in descending
order on the basis of their cgpa. Display the names of all the students who are
eligible for Verizon placement drive.
(Eligibility: cgpa >=7.5 )
3. Write a
program which prompts the user to enter N integers and store them in an
arraylist. Now implement a method which accepts an arraylist containing
duplicate values and returns a Collection having unique elements only.
public
Collection removeDuplicate(ArrayList<T extends Number> al)
Display all
the integer values after removing the duplicates.
4. Write a
program which prompts the user to enter a String. Now implement a method to
check whether the String is palindrome or not? public
boolean isPalindrome(String str)
Invoke the isPalindrome method and if the String is
not palindrome then throw a user defined exception NOT_PALINDROME_EXCEPTION
which displays “String is not palindrome” when the exception object is printed.
Handle the exception using try-catch blocks.
5. Write a
program to define a class Car having attributes name, mileage and price. Create
5 Car objects and store them in a file named as Cars.txt.
Write a method public void getCars(int amt)
which displays the name, mileage and price of all the cars having price less
than amt. [Use Object Input/Output Stream]
6. Write a
program which reads the name of two files f1 and f2 using the command-line
arguments. Now append the contents of f1 into f2.
Now read a message from the console using Scanner and
append at the end of File f2 and display the contents of f2 on console.
7. Write a
program which reads two integers from the command-line argument and handle the
possible exceptions using try-catch and if exception occurs, ask to re-enter
the numbers and read using Scanner. Now invoke the public int divide(int
a, int b) method and display the result of dividing a by b. Handle the
exception in division also. Demonstrate the importance of finally block in this
program.
8. Write a
program to create an interface Demo with a static method testStatic(), a
default method testDefault() and an abstract method testAbstract().
Define two interfaces X and Y with an abstract method
void test() in each of them.
Define an abstract class MyAbstract which inherits X
and Y.
Implement a class MyClass which inherits MyAbstract,
Demo and X. Create an object of MyClass and invoke testStatic, testDefault,
testAbstract and test methods.
9. WAP in
which define an abstract class A containing a non-abstract method demo() and an
integer variable x initialized to 10. Define an interface B containing a
default method void demo() and a double variable x initialized with 20.0. Now create a class Test which
inherits A and B and override the demo method. Invoke the demo() method of
Interface and the class Test both and print the value of x.
10. Write a
program to define an interface Person containing abstract method VoterId
getVoterID().
Create a class Employee which inherits Person and
contains an inner class VoterId with attributes id and name. Implement the
getVoterId method such that it reads the name and automatically assigns a
unique id to each Employee Object and return the VoterId object.
Create a Main class and create two Employee objects
and display their Voter Ids.
from where i will get these answere ?
ReplyDeleteWhat we will do with these questions.If we were able to solve these questions by our own,
ReplyDeletethen we will be able to perform the same in exams also.
What about the solutions to these questions?
ReplyDeletePlzz give also the solutions atleast littlebit hints,,, plzzz
ReplyDeleteNice blog..! I really loved reading through this article... Thanks for sharing such an amazing post with us and keep blogging...Java Training in Chennai
ReplyDeleteJava Training Institute in Chennai
Thanks for sharing this valuable information i like it. This is very useful for Freshers. I Can share this with my friend circle. Keep Updates for Useful Information...
ReplyDeleteJava Training in Delhi
VERY HELPFULL POST
ReplyDeleteTHANKS FOR POSTING
R Programming Institute in Delhi
Graphic Design Insititute in Delhi NCR
Advanced Excel Insitute in Delhi
Mean Stack Training in Delhi
SASVBA
GMB
for more info:
It is amazing and wonderful to visit your site. Thanks for sharing information; this is useful to us....
ReplyDeleteMERN Stack Training in Delhi