0% found this document useful (0 votes)
27 views2 pages

Labs

Uploaded by

Akshay Jawale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Labs

Uploaded by

Akshay Jawale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1)Accept mobileno & print ContactPerson Name[HashMap]

2)Accept CityName & print its stdcode


Properties p=new Properties();
p.put("Pune","020");
__________________________________________________________________
3)wap to store friendnames in an ArrayList & print it in a sorted manner using
iterator
Collections.sort(lst); used to explicitly sort a collection
__________________________________________________________________

4)wap to store book details in a Stack.& pop last book


write a Book class(code,title,author,price)

Stack st=new Stack();


st.push(new Book(1001,"Let Us C","Y K",670);
__________________________________________________________________

5)wap to create a HashSet containing Customer objects and print it


**replace HashSet by TreeSet
HashSet hs=new HashSet();
hs.add(new Customer(...));

__________________________________________________________________

************************Challenge Assignments
6)
Accept cityname & print its information[cityname,state,info,touristplaces]

store cityname as key & CityInfo object as value in


HashMap

HashMap<String,CityInfo> hm=new HashMap<>();


hm.put("Pune",new CityInfo(....));
hm.put("Mumbai",new CityInfo(....));
hm.put("Jaipur",new CityInfo(....));

class CityInfo{
String cityname,state,info,touristplaces
}

CityInfo cinfo=hm.get(city);

__________________________________________________________________

7)write a
class Director{
int regNo;
String directorname;
ArrayList<Movie> movies;
}

create object of Director using default ctor


pass data using setter methods
& print object using display
__________________________________________________________________

8)write a method printCollection which can print objects of any type


use generics with wild card ?
HashSet<Manager> c1=new HashSet<>();
ArrayList<Product> c2=new ArrayList<>();
Stack<Book> c3=new Stack<>();

printCollection(c1);
printCollection(c2);
printCollection(c3);

__________________________________________________________________

You might also like