0% found this document useful (0 votes)
52 views29 pages

Java Practical Exam Guidelines

The documents provide instructions for 10 practical exams on Java programming. The exams cover topics like threads, collections, I/O and databases. Students will complete programming tasks and there will be a viva voce round.

Uploaded by

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

Java Practical Exam Guidelines

The documents provide instructions for 10 practical exams on Java programming. The exams cover topics like threads, collections, I/O and databases. Students will complete programming tasks and there will be a viva voce round.

Uploaded by

vivekdj048
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Savitribai Phule Pune University

[Link].(Computer Science)Sem-VI Practical Examination


CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

[Link] a Java program to display all the alphabets between ‘A’ to ‘Z’ after every 2 seconds.
[15M]

2. Write a Java program to accept the details of Employee(Eno, EName, Designation,


Salary)from a user and store it in to the database. (UseSwing) [15M]

[Link] [05M]

1
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

[Link] a java program to read ‘N’ names of your friends, store it into HashSet and display
the min ascending order. [15M]

[Link] a program to solve producer consumer problem in which a producer


produces a value and consumer consume the value before producer generate the
next value.(Hint:use thread synchronization) [15M]

[Link] [05M]

2
Savitribai Phule Pune University
[Link].(ComputerScience)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
PracticalDuration:3Hours [Link]

-----------------------------------------------------------------------------------------------

[Link] a program in which thread sleep for 6 sec in the loop in reverse order
from 100 to 1 and change the name of thread. [15M]

[Link] a Java program to create LinkedList of String objects and perform the following:
i. Add element at the end of the list
ii. Delete first element of the list
iii. Display the contents of list inreverse order [15 M]

[Link] [05M]

3
Savitribai Phule Pune University
[Link].(ComputerScience)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a Java program using Runnable interface to blink Text on the frame.[15M]

2. Write a Java program to store city names and their STD codes using an appropriate
collection and perform following operations:
i. Add a new city and its code(Noduplicates)
ii. Remove a city from the collection
iii. Search for a city name and display the code [15 M]

3. Viva [05M]

4
SavitribaiPhulePuneUniversity
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming usingJava–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a Java program to accept ‘n’ integers from the user and store them in a collection.
Display them in the sorted order. The collection should not accept duplicate elements.
(Useasuitablecollection).Searchforaparticularelementusingpredefinedsearchmethod
intheCollection framework. [15M]

2. Write a java program to simulate traffic signal using threads. [15 M]

3. Viva [05M]

5
Savitribai Phule Pune University
[Link].(ComputerScience)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a java program that implements a multi-thread application that has three threads.
First thread generates random integer number after every one second, if the number is
even; second thread computes the square of that number and print it. If the number is
odd, the third thread computes the of cube of that number and print it.[15M]

2. Write a java program for the following:


i. To create a Product(Pid, Pname, Price)table.
ii. Insert at least five records into the table.
iii. Display all the records from a table. [15 M]

3. Viva [05M]

6
Savitribai Phule Pune University
[Link].(ComputerScience)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

Write a java program to define a thread for printing text on output screen for ‘n’number
of times. Create 3 threads and run them. Pass the text ‘n’ parameters to the thread
constructor.
Example:
i. First thread prints“COVID19” 10times.
ii. Second thread prints “LOCKDOWN2020” 20times
iii. Third thread prints “VACCINATED2021” 30times [15 M]

2. Write a java program to read ‘n’ names of your friends, store it into
linkedlist, also display contents of the same.
[15M]

3. Viva [05M]

7
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a Java program to create a thread for moving a ball inside a panel vertically. The
ball should be created when the user clicks on the start button. [15M]

2. Write a program to sort HashMap by keys and display the details be for sorting and
after sorting. [15M]

3. Viva [05M]

8
Savitribai Phule Pune University
[Link].(ComputerScience)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a program to create a new treeset, add some colors(string) and


print out the treeset.
[15M]
[Link] a java program for the following:

i. To create a Product(Pid, Pname, Price)table.


ii. Insert at least five records into the table.
iii. Display all the records from a table. [15 M]

[Link] [05M]

9
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------
1. Write a program in which thread sleep for 6 sec in the loop in reverse order
from 100to1 and change the name of thread.
[15M]

2. Write a Java Program to create a PROJECT table with field’s project_id, Project_name,
Project_description, Project_Status. Insert values in the table. Display all the details of
the PROJECT table in a tabular format on the screen.(using swing). [15M]

3. Viva [05M]

10
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a Java program to display information about the database and list all the tables in
the database.(Use Database Meta Data). [15M]

2. Write a Java program to show lifecycle (creation, sleep, and dead) of a thread. Program
should print randomly the name of thread and value of sleep time. The name of the
thread should be hard coded through constructor. The sleep time of a thread will be a
random integer in the range 0 to 4999. [15M]

3. Viva. [05M]

11
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

[Link] a program that implements a multi-thread application that has three [Link]
thread generates random integer every 1 second and if the value is even, second thread
computes the square of the number and prints. If the value is odd, the third thread will print
the value of cube of the number
[15M]

2. Accept ‘n’ integers from the user. Store and display Integers in sorted order
having proper collection class. The collection should not accept duplicate
elements. [15M]

1. Viva [05M]

12
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a java program to create a TreeSet, add some colors (String) and print out
thecontentofTreeSetinascendingorder. [15M]

2. Write a Java program to accept the details of Teacher (TNo,TName, Subject). Insert
atleast 5 Records into Teacher Table and display the details of Teacher who is
teaching“JAVA”Subject.(UsePreparedStatementInterface) [15M]

3. Viva [05M]

13
Savitribai Phule Pune University
[Link].(ComputerScience)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a java program to accept ‘N’ integers from a user. Store and display integers in
sorted order having proper collection class. The collection should not accept duplicate
elements.
[15M]

2. Write a Multithreading program in java to display the number’s between 1 to 100


continuously in a Text Field by clicking on button.(Use Runnable Interface).
[15M]

3. Viva [05M]
14
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a java program to accept ‘N’ Integers from a user store them into LinkedList
Collection and display only negative integers. [15M]

2. Create a PROJECT table with fields project_id, Project_name,


Project_description,Project_Status. [Link] values in the table. Display all the details
of the PROJECT table in a tabular format on the screen. [15M]

3. Viva [05M]

15
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

[Link] a program to display information about the database and list all the tables
in the database.(Use Database MetaData). [15M]

[Link] a program to sort HashMap by keys and display the details before
sorting and after sorting. [15 M]

[Link] [05M]

16
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a java program to accept ‘N’ Subject Names from a user store the min
toLinkedList Collection and Display them by using Iterator interface. [15M]

2. Write a java program to solve producer consumer problem in which a producer


produces a value and consumer consume the value before producer generate the
nextvalue.(Hint:use thread synchronization) [15M]

3. Viva [05M]

17
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a Menu Driven program in Java for the following: Assume Employee table with
attributes (ENo, EName, Salary) is already created. 1. Insert 2. Update 3. Display
[Link]. [15M]

2. Write a program in which thread sleep for 6 sec in the loop in reverse order
from 100 to1 and change the name of thread.
[15M]

3. Viva [05M]

18
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a java program to accept a String from a user and display each vowel from
aString after every 3 seconds. [15M]

2. Write a java program to accept ‘N’ student names through command line, store
themintothe appropriate Collection and display them by using Iterator and ListIterator
interface. [15M]

3. Viva [05M]

19
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

[Link] a java program to scroll the text from left to right continuously. [15M]

[Link] to define a thread for printing text on output screen for ‘n’ number of
times. Create 3 threads and run them. Pass the text ‘n’ parameters to the thread
constructor. Example:
1. First thread prints “COVID19” 10times.
2. Second thread prints “LOCKDOWN2020” 20times
3. Third thread prints “VACCINATED2021” 30times [15M]

[Link] [05M]
20
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a Java program to delete the details of given employee(ENo.,


ENameSalary).Accept employeeID through commandline.(Use PreparedStatement
Interface)
[15M]

2. Write a java program to accept names of ‘n’ cities, insert same into array
list collection and display the contents of same arraylist, also remove all
these elements.
[15M]

3. Viva [05M]

21
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Accept ‘n’ integers from the user. Store and display integers in sorted
order having proper collection class. The collection should not accept
duplicate elements.
[15M]

2. Write a program to display information about the database and list all the
tables in the database.(Use Database MetaData).
[15M]

3. Viva [05M]
22
Savitribai Phule Pune University
[Link].(Computer Science)Sem-VI Practical Examination
CS-369: Practical Course based on CS 365
(Object Oriented Programming using Java–II)
Practical Duration:3Hours [Link]

-----------------------------------------------------------------------------------------------

1. Write a java program for the implementation of synchronization. [15 M]

2. Write a Java Program for the implementation of scrollable ResultSet. Assume Teacher
table with attributes (TID,TName,Salary) is already created. [15M]

3. Viva [05M]

23

Common questions

Powered by AI

Best practices for sorting and displaying large datasets in Java using the collection framework include choosing an appropriate collection type based on the data characteristics and operations required. For instance, using a TreeSet can automatically maintain order and prevent duplicates. Sorting can also be simplified using built-in methods such as Collections.sort for lists. Utilizing comparator objects or the Comparable interface within custom objects can provide flexibility in defining sorting criteria. When displaying, iterating through data using efficient techniques such as the forEach method can improve performance. Additionally, employing streams for processing and filtering can enhance readability and reduce boilerplate code while handling datasets .

Advantages of using Java's LinkedList collection include dynamic size adjustment and efficient element insertion and removal, especially at the head or tail. It excels in scenarios needing frequent modifications since it doesn't require shifting elements, unlike ArrayList. However, a potential drawback is its inefficiency for indexed access, as it must traverse elements sequentially from the start or end, resulting in O(n) complexity for accessing elements by index. Additionally, LinkedList consumes more memory because each element maintains links to its neighbors, which might be unnecessary for static-size or indexed-centric operations .

To ensure efficient removal and re-addition of elements in Java collections, techniques such as using iterators for element removal with Iterator's remove method can prevent ConcurrentModificationExceptions from occurring. Using collections like LinkedList can make removals and additions more efficient due to their dynamic node structure. Maintaining consistent iterable access through the ListIterator can allow bidirectional traversal and element manipulation efficiently. When order is important or duplicates must be avoided, using a LinkedHashSet could be beneficial, as it maintains insertion order and prevents duplicates. Understanding the algorithmic complexity and memory requirements of each collection type aids in choosing the most efficient one for the task .

Java provides several ways to manage and manipulate data structures like HashMaps for sorting. Since HashMaps do not maintain order, one needs to copy the entries into another suitable data structure like a TreeMap, which maintains a sorted order based on natural ordering or a specified comparator. Alternatively, one could extract the entries into a list, and then sort this list using Collections.sort, providing a custom Comparator to define the desired key or value sorting. Once sorted, these entries can be printed or used further. These processes leverage key aspects of Java's collections framework and are efficient for handling dynamic and unordered datasets .

Java's multithreaded features can simulate real-world scenarios like traffic signals by using threads to represent different traffic lights and control their timing. Each thread can handle one light and sleep for a specified duration representing the light duration before switching states. Synchronization mechanisms must ensure proper sequence without conflicts; using synchronized regions or higher-level constructs like CyclicBarrier can manage transitions. Using an enum for light states simplifies state management. This kind of application highlights Java's strength in concurrent execution and resource management, essential for simulating time-sensitive real-world conditions .

To manage multi-threading effectively in Java for complex tasks such as simulating a producer-consumer problem, one can use thread synchronization techniques to handle the resource sharing between producer and consumer threads. The producer must produce a value before the consumer consumes it, necessitating the use of synchronization tools like locks or monitors to safely manage access. The Java programming language provides synchronized methods or blocks and built-in monitor objects to facilitate this. Furthermore, one could use higher-level concurrency utilities provided in the java.util.concurrent package, such as the BlockingQueue interface, which handles all the necessary synchronization internally. These approaches ensure that shared resources are accessed in a thread-safe manner, preventing race conditions and ensuring data integrity .

Java's concurrency utilities enhance the development and performance of multi-threaded applications by providing high-level abstractions that simplify thread management and execution. These include thread pools, executors, and synchronization aids like CountDownLatch, Semaphore, and CyclicBarrier that help manage complex thread interactions efficiently. The Concurrent Collections framework (such as ConcurrentHashMap) offers concurrent-safe structures that improve performance and reduce the need for manual synchronization. By managing resource sharing and avoiding common pitfalls like deadlocks and race conditions, these utilities make multi-threaded applications more robust and scalable .

Implementing a thread lifecycle demonstration in Java poses challenges such as managing state transitions and ensuring accurate status reporting. Each thread must correctly and synchronously report its status as "new," "runnable," "blocked," "waiting," "timed waiting," or "terminated." These states can involve complex interactions, such as ensuring a thread wakes from a "sleep" state or terminates gracefully. Overcoming these challenges involves careful use of synchronization mechanisms to coordinate state changes, employing Java's Thread class methods like sleep(), join(), and interrupt(), and ensuring that any waiting for resources is properly aligned with state transitions. Debugging tools and consistent logging can also help track and verify each state transition within the thread lifecycle .

Java's PreparedStatement interface improves security by preventing SQL injection attacks. It allows developers to define queries with placeholder values represented by question marks (?), which can then be securely set using setter methods. This separation of query logic from data manipulation ensures that input data is treated strictly as data rather than executable code. Efficiency is improved because PreparedStatement can precompile SQL statements, allowing them to execute more quickly when repeatedly used. The interface also enhances code clarity and maintainability by abstracting complex SQL formatting operations away from the core application logic .

Technical considerations when designing a Java application involving database metadata queries include ensuring the JDBC driver provides comprehensive metadata support and setting up accurate database connections. Developers must handle exceptions effectively and manage resources using try-with-resources statements to avoid leaks. The DatabaseMetaData interface should be utilized effectively for retrieving schema and table information, considering performance impacts of large metadata queries. Security concerning database credentials and access permissions is critical, as is considering transaction isolation levels if metadata queries are conducted alongside data manipulations. Efficient caching techniques can also enhance performance if metadata is repeatedly accessed .

You might also like