java and lab
java and lab
23UCSCP44
Units Contents Required Hours
I 1. Write a Java program that prompts the user for an integer 48
and then prints out all the prime numbers up to that
Integer?
2. Write a Java program to multiply two given matrices.
3. Write a Java program that displays the number of
characters, lines and words in a text?
4. Generate random numbers between two given limits
using Random class and print messages according to the
range of the value generated.
5. Write a program to do String Manipulation using
Character Array and perform the following string
operations:
a. String length
b. Finding a character at a particular position
c. Concatenating two strings
6. Write a program to perform the following string
operations using String class:
a. String Concatenation
b. Search a substring
c. To extract substring from given string
7. Write a program to perform string operations using
StringBuffer class:
a. Length of a string
b. Reverse a string
c. Delete a substring from the given string
8. Write a java program that implements a multi-thread
application that has three threads. First 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.
9. Write a threading program which uses the same method
asynchronously to print the numbers 1 to 10 using
Thread1 and to print 90 to 100 using Thread2.
10. Write a program to demonstrate the use of following
exceptions.
a. Arithmetic Exception
b. Number Format Exception
c. Array Index Out of Bound Exception
d. Negative Array Size Exception
11. Write a Java program that reads on file name from the
user, then displays information about whether the file
exists, whether the file is readable, whether the file is
writable, the type of file and the length of the file in
bytes?
12. Write a program to accept a text and change its size
and font. Include bold italic options. Use frames and
controls.
13. Write a Java program that handles all mouse events and
shows the event name at the center of the window when
a mouse event is fired. (Use adapter classes).
14. Write a Java program that works as a simple calculator.
Use a grid layout to arrange buttons for the digits and for
the +, -,*, % operations. Add a text field to display the
result. Handle any possible exceptions like divide by
zero.
15. Write a Java program that simulates a traffic light. The
program lets the user select one of three lights: red,
yellow, or green with radio buttons. On selecting a
button, an appropriate message with “stop” or “ready” or
“go” should appear above the buttons in a selected color.
Initially there is no message shown.
Course Code Java Programming Credits 5
23UCSCC43
Lecture Hours: (L) 5 Tutorial Hours : Lab Practice Total: (L+T+P)
per week (T) per week Hours: (P)per week per week 5
Course Category : Year & Semester: II & IV Admission Year: 2023
Pre-requisite
Links to other Courses
Learning Objectives: (for teachers: what they have to do in the class/lab/field)
To provide fundamental knowledge of object-oriented programming.
To equip the student with programming knowledge in Core Java from the basics up.
To enable the students to use AWT controls, Event Handling and Swing for GUI.
Course Outcomes: (for students: To know what they are going to learn)
CO1: Understand the basic Object-oriented concepts.
Implement the basic constructs of Core Java
CO2: Implement inheritance, packages, interfaces and exception handling of Core Java.
CO3: Implement multi-threading and I/O Streams of Core Java
CO4: Implement AWT and Event handling.
CO5:Use Swing to create GUI.
Recap: (not for examination) Motivation/previous lecture/ relevant portions required for the
course) [ This is done during 2 Tutorial hours)
Units Contents Required Hours
I Introduction: Review of Object Oriented concepts - 9
History of Java - Java buzzwords - JVM architecture -
Data types - Variables - Scope and life time of variables -
arrays - operators - control statements - type conversion
and casting - simple java program - constructors - methods
- Static block - Static Data - Static Method String and
String Buffer Classes
II 9
Inheritance: Basic concepts - Types of inheritance -
Member access rules - Usage of this and Super key word -
Method Overloading - Method overriding - Abstract classes
- Dynamic method dispatch - Usage of final keyword.
Packages: Definition - Access Protection - Importing
Packages.
Interfaces: Definition – Implementation – Extending
Interfaces.
Exception Handling: try – catch - throw - throws – finally –
Built-in exceptions - Creating own Exception classes.
III 9
Multithreaded Programming: Thread Class - Runnable
interface – Synchronization – Using synchronized
methods – Using synchronized statement - Interthread
Communication – Deadlock.
IV 9
AWT Controls: The AWT class hierarchy - user interface
components- Labels - Button - Text Components - Check
Box - Check Box Group - Choice - List Box - Panels – Scroll
Pane - Menu - Scroll Bar. Working with Frame class - Colour
- Fonts and layout managers.
Web resources