tutorial problems jp answers

Upload: shanthinisampath

Post on 05-Mar-2016

242 views

Category:

Documents


1 download

DESCRIPTION

Java programming tutorial problems WITH ANSWERS

TRANSCRIPT

SNS College of Technology (An Autonomous institution)CoimbatoreDEPARTMENT OF INFORMATION TECHNOLOGYIT 302- JAVA PROGRAMMINGTUTORIAL PROBLEMS

Tutorial - #1

1. Print each of the following patterns. Use one System.out.println(...) statement for each line of outputs. a. * * * * * * * * * * * * * * *b. * * * * * * * * *c. * * * * * * * * * d. * * * * * * * * *e. * * * * * * * * * * *f. (a) (b) (c)

2. The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return true if we sleep in.

Q-2 Given two int values, return their sum. Unless the two values are the same, then return double their sum.

3. Q-3 Given an int n, return the absolute difference between n and 21, except return double the absolute

Tutorial - # 2 (conditional loops)

4. Create a BMI Calculator with following slabsBMI category

less than 15.0 very severely underweight

15.0 to 16.0 severely underweight

16.1 to 18.4 underweight

18.5 to 24.9 normal weight

25.0 to 29.9 overweight

30.0 to 34.9 moderately obese

35.0 to 39.9 severely obese

40.0 and up very severely (or "morbidly") obese

5. Implement a simple quiz (on general knowledge ) 6. Write a program to convert given no. of days into months and days.

Tutorial - # 3 (inheritance)

7. Sell Now manages an online advertisement site, where users can advertise about various products they want to sell. Users can post advertisements to sell various products. Users need to provide the category of the product (e.g Electronics, Books, Textiles, and Vehicle etc), brand of the product (e.g Nokia, Reebok, etc.). User can anytime remove the advertisement. Write a program toa.Register a userb.Post an advertisementc.Remove an advertisement.

8. Keep Talking is a leading mobile communication service provider in the country. They offer post-paid mobile connection services across cities. There are various tariff plans they offer to customers. Customers calls are charged based on the plan they have opted for. Write a program to:a.Calculate bill of a customerb.Find number of customer who have opted for a particular tariff planc.Find the connection with the highest bill

9. Accept name, address, rollno, percentage with base class and cast annual income in derived class and check if scholarship is sanctioned or not. If cast is not open and annual income is less than 100000 then scholarship is sanctioned.

Tutorial - # 4 (overriding )

10. Define an Employee class with suitable attributes having getSalary() method, which returns salary withdrawn by particular employee. Write class Manager which extends class Employee, override the getSalary() method, which will return salary of manager by adding travelling allowance, house rent allowance etc.

11. Create an abstract class Person. Define 2 classes Employee and Worker from it. Use Proper method to accept and display the details for the same. The fieldsof Employee are Emp_no, Emp_name, address. Similar fields for worker are name and working hours.

Tutorial - # 5 Dynamic proxies & reflexion

12. Create an Interface called cineHall with methods availability () and cost (). Create class named Booking which implements the interface cineHall. Create another class called ClientBooking which calls the functions of Booking class. Create a proxy class called proxyBooking to exhibit the ability of proxies in accessing the booking class

Tutorial # 6 File I/O & Exception handling

13. Program for counting no. of Chars, Words and Lines in a file14. Creating a Shared File Lock on a File

Tutorial # 7 String and String Buffers

15. Write a program to find the no of occurrence of string find in the following string wefindyoufindtheyfindtheydidntfind,

16. Write program to perfrom all the

Tutorial # 8 collection classes

17. Create a doubly linked list using collection class18. Implement stack operations using Array List19. Implement queue operations using Array List

Tutorial # 9 Threads

20. Create thread to perform multiplication table.

Tutorial # 10 Thread Communication

21. Create a gui based chat program using threads

Tutorial # 11 Generic classes22. Implement bubble sort 23. Implement singly linked list operation

Tutorial # 12 Applets 24. Create applet to and display a banner in it25. Create an applet draw a smiley on it

Tutorial # 13 Frames & swings26. Create a chat between two frames27. Write a swing program to make scientific calculator

Tutorial # 14 Event Handling 28. Program to create GUI for Bank Account Simulation29. Write a program to change the foreground and background colors of and applet On click

Tutorial # 15 Animation

30. Create a clock in applet. 31. Make a ball move round window