Вы находитесь на странице: 1из 9

Java stream Lab Exercises

Core Java

Introduction & basic elements of Java (4)


1. Write a program in to display a message as follows: Welcome to the world of Java 2. Write a program to find out the prime factorials of a number. 3. Write a program to get the binary equivalent of a number. 4. Write a Java application which takes several command line arguments, which are supposed to be names of students and prints output as given below: (Suppose we enter 3 names then output should be as follows): Number of arguments = 3 a: First Student Name is =Tom b: Second Student Name is =Dick c: Third Student Name is =Harry 5. Arrange an array of elements in ascending order using selection sort algorithm. 6. Create an array that stores 20 integers. Display sum and average of the integers. Also, display the number of values less than the average. 7. A set of 5 words is given. Write a program to reverse each word and arrange the resulting words in alphabetical order. 8. A shopkeeper sells three products whose retail prices are as follows: Product 1, 22.5; product 2, 44.50; and product 3, 9.98. Write an application that reads a series of pairs of numbers as follows: a)product number and b)quantity sold Your application should use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. Use a loop to determine when the application should stop looping and display the final results. 9. Write a program to print the series: 0,1,4,9,16,.....625

Classes & Methods (8)


1. 2. Write a java program that allows you to create only one instance of a class President. Write a class Define a class to represent a bank account. Include the following members: a. Data Members: b. Name of the Depositor c. Account Number d. Type of Account e. Balance amount in the account Data Methods:

a. b. c. d. 3. 4. 5. 6. 7. 8.

To assign initial values To deposit an amount To withdraw an amount To display name and balance.

Create a class called Student with the following details: RollNo, StudName, MarksInEng, MarksInMaths and MarksInScience. Display the total marks and Percentage of the student. Write a Menu driven application in java that demonstrate a use of Stack and Queue. (Hint : Use Different class for Stack and Queue) Create a class called Calculator which has 4 methods add, diff, mul and div. Create an application to access these methods. Create a anonymous block and demonstrate when the method is called. Create a class called car. When the car object is created, it should be initialized with regno,ownername, company name. Write display function to display the details of the car. For the problem No.2, find out no. of accounts created.

Packages (2)
1. Write a program in java to show the difference between protected and default members of a class. (within a package and across the package how it differs) 2. A program in java to show that private members of a super class cannot be accessed from derived classes

Inheritance (4)
1. Create the classes required to store data regarding different types of courses that employees in a company can enroll for. All courses have name and course fee. Courses are also either classroom delivered or delivered online. Courses could also be full time or part time. The program must enable the course coordinator to register employees for courses and list out employees registered for specific courses. 2. Write a java program in to create a class Worker. Write classes DailyWorker and SalariedWorker that inherit from Worker. Every worker has a name and a salaryrate. Write method Pay (int hours) to compute the week pay of every worker. A Daily worker ia paid on the basis of the number of days she/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. (Hint: Polymorphism) 3. Write a java to create a Player class. Inherit the classes CricketPlayer, FootballPlayer and HockeyPlayer from Player class. 4. Create a class called vehicle and inherit the properties of vehicle to Car. Create a constructor in Car class -- reuse the vehicle class constructor.

Interface (2) 1. Create an Interface called Calculator. Implement it and access the services for addition and
subtraction from an application. 2. Create an interface called Polygon with a method called area. Create three classes named rectangle, square and triangle that implement the interface. Write an application to access the methods.

Inner classes (2)


1. Create a class to implement stack operation and create an inner class to iterate the elements of the stack.

Exception handling (5)


1. Create a user defined exception to check whether your employee exist in your data structure (use any data structure to store the employees - like array, ArrayList etc) and throw exception if name is not in the employees list. Create a user defined exception to handle this case. Use appropriate data structure to store employee information. 2. Write a program in Java to display the names and roll numbers of students. Initialize respective array variables for 10 students. Handle ArrayIndexOutOfBoundsException, so that any such problem doesn't cause illegal terminations of program. 3. Create an Exception called NegativeNumberException. Write a java application to use the same. 4. Write a java program to enable the user to handle divide by zero exception.

Threads (4)
1. Write a program that picks up a question from an array containing 10 elements and displays the question. It then waits 30 seconds for the user to answer. If user answers it correctly, then it moves to the next question otherwise terminates the program. 2. Write a java program to create a class called FileWatcher that can be given several filenames that may or may not exist. The class should start a thread for each file name. Each thread will periodically check for the existence of its file. If the file exists, the thread will write a message to the console and then end. 3. Write a java program to create a class called FileWatcher that can be given several filenames that may or may not exist. The class should start a thread for each file name. Each thread will

periodically check for the existence of its file. If the file exists, the thread will write a message to the console and then end. 4. Automatically create and delete a file(set timer)

Primitive wrappers (4)


1. 2. 3. 4. Parsing and Formatting a Number into Binary, Octal, and Hexadecimal Convert a Float Object into a String object Convert decimal integer to Octal Find maximum of two numbers using Math.max.

java.util classes (5)


1. 2. 3. 4. 5. Write an application to count total number of occurences of a String in a text file Write a java program to convert a String to Hex Write an application to count total number of occurences of a String in a text file A program in java to create a Log File Write a program to implement Gregorian Calendar

Collections and Generics (4)


1. Write a program to implement a telephone directory. 2. A program in java create a stack classs of variable size with push() and pop() methods. 3. Create a class called CD whose attributes are Title and singer. Arrange the CDs in ascending order based on the singer name. (What sorting algorithm would you use for this?) 4. Create a Collection and initialize with a HashSet object, ArrayList object and HashMap object. Write a function to identify the type of object at run time.

I/O(5)
1. 2. 3. 4. Create a java program to list files or subdirectories in a directory. Write a java program to move a file or directory to another directory. Copy the content of one file to another using byte stream and character stream. Create an object called emp whose attributes are empid, ename and sal. Serialize and deserialize the same. 5. Write an application to Serialize the above object except for the sal atritube. (use transient)

XML

Introduction to XML & Schema (4)


1. Create a XML file for library. Library can have n number of books. Each book should have ISBN of the book, title of the book, the first & last names of the author of the book, the price of the book and the category of the book. (library.xml) 2. Create DTD and XSD for Q.1. 3. Create a XML file for Trainee. Each trainee should have sapid, name and stream. 4. Create XSD for Q.3.

Styling, XSLT, XPath (6) 1. Create a XSLT sheet for document from question 1 above and display all the books in a table
format. The headings should be in pink color. Books priced above Rs, 1000 should be highlighted in green. 2. For library.xml a) b) c) d) e) f) select all the titles. Select the title of the first book. Select all the first names Select all the last names Select all the prices. Select the price nodes with > 1000

XSL-FO, XPointer, XLink, XML Parsers (4)

1. Create a list using xsl-fo for displaying the core topics of java. 2. Create a table using xsl-fo for displaying the name of books and price.

JavaScript

JavaScript Basics (4)


Create a page that displays text and an image. Track how many times a user has visited your page by storing this information in a cookie. Display this information to the user, e.g. You have visited x number of times! The current visit should be included in this number. Display the date and time of the user's last visit, e.g. You lasted visted on... If this is the user's first visit, display e.g. "You have never visited before."

DOM, Predefined classes (4)


1. Create a XML file for library. Library can have n number of books. Each book should have ISBN of the book, title of the book, the first & last names of the author of the book, the price of the book and the category of the book. 2. Parse the above document using DOM parser

Object Hierarchy (4)

1. 2. 3. 4.

Write javascript code to find the length of a string. Display todays date and time using javascript. Sort an array alphabetically Search for a text in string and return the text if found.

JEE

JDBC (4)

1. Write a pgm in Java to Read ,Update and Delete any record from the Element table. The table Element has following fields (Atomic weight, Name and Chemical symbol). The input should be provided through Command Line Argument along with the appropriate data.. 2. Create a procedure called updateprocedure which will update the salary of an employee. Update the salary of an employee by calling the procedure and passing the employee id of a particular employee. Create relevant tables for this. 3. List the employees from the employee table. Display the first, nth and last record in that list. 4. Display the set of employees and the make the records only readable.

Servlet Basics (4)


1. Display Date in a servlet 2. Display Headernames and values in a servlet 3. Pass username and password from login servlet, receive it in a servlet and display both.

Servlet initialization (4)


1. Pass username and password using initparam tag in web.xml and receive the values in a servlet using servletconfig. 2. Create a counter variable in context-param tag of web.xml and each time when the web application is accessed it should be increased by 1. 3. Create a Filter to filter the request from a particular ipaddress. If it is a filtered IP the access for a particular servlet should be forbidden. Otherwise, the request can be processed and give access to the relevant servlet.

Servlet communication (4)

1. Create a login page, validate it in a servlet, redirect it to home page or failure page using include and forward method of request dispatcher. 2. For Q1. Use sendredirect method.

DataSource (2)
1. Create a datasource. Create a servlet to add, delete and update records in the backend using servlet. 2. Create a login application and validate username and password using datasource.

Session Handling & Servlet Listener (4)

1. Initialize an employee object in the servlet listener and when the application starts and change the attributes. 2. Create cookies and store string objects in get method of a servlet and display the values in the post method of the same servlet. 3. Use hidden variables and pass parameters to servlet.

JSP Basics (4)


1. Design a Login page using HTML. When you click the submit button it has to go to Servlet wherein you check for the validity of your username and password. 2. Create a jsp page wherein two numbers need to be provided as input. Find out the sum and display it in a page called result and, if there is any exception, display it in a error page

JSP Standard Action Tags (2)


1. Design a HTML page which contains Name and age of a person. Receive it in bean and display the values. 2. Use Jsp:forward to transfer the control to a static page.

Working with Files and Applets (2)


1. Create an applet with a button. When the button is clicked it should change the background color. Use jsp tag.

JSP 2.0 Expression Language (4)


1. Declare , store and display variables. 2. Select the records from a employee table using sql tag.

Custom Tags (4)


1. Create a custom defind tag with attribute . 2. Create a custom defined tag which should find out the substring of a given string.

Web Services (8)


1. Create a web service which converts temperature in Celsius to Fahrenheit. 2. Create a web service to calculate simple interest.

Design Patterns (4)


1. Create a singleton class.

Struts

Struts Framework & Struts Tags (4)


1. Design a registration form which contains username, password, gender, country, which community(java, .net etc.,) using struts tags. 2. Create a currency converter application using struts bean tag.

Validation Framework & other concepts (4)


1. Create an application to validate login page. 2. Validate a login page using XML File 3. Create a struts application to transfer the data to domain object by params interceptor

Hibernate

Introduction (4)
1. Create a table called Student in mysql wherein the primary key must be generated automatically in Hibernate.

O/R Mapping & working with databases (4)


1. Establish a one-to-many relationship between student and address. 2. Create a database in the backend. Write a java application to insert, delete and update records. 3. Establish a one-to one relationship between student and Phone.

Вам также может понравиться