Core Java Laboratory details
Core Java Laboratory
Course Code: CAS41M MP302
Course Name: Practical Based on Core Java
Pre-requisites: Knowledge of Programming
Language C or C++ is helpful.
Course Objectives:
1.
To learn how to implement object-oriented designs with Java.
2.
To understand fundamentals of programming such as variables, conditional
and iterative execution, methods, etc.
Course Outcomes:
At the end
of this practical course, students will be able to:
- CO 1: Use an
integrated development environment to write, compile, run, and test simple
object-oriented Java programs.
- CO 2:
Validate input effectively in a Java program.
- CO 3:
Understand and apply the use of abstract classes.
- CO 4: Design
and implement classes, objects, members of a class, and the relationships
among them needed for a specific problem.
General Guidelines for Practical Sessions:
- Preparation: Review
the relevant theoretical concepts from the Core Java (CAS41MML302)
syllabus before attending each practical session.
- IDE
Usage: All practicals should be implemented,
compiled, and executed using a Java IDE. ( Write
few programs in notepad compile and execute them on commad
line.)
- Code
Quality: Write clean, well-commented, and readable code. Use meaningful
variable names and follow standard Java coding conventions.
- Input
Validation: Where applicable, ensure your programs handle invalid user input
gracefully.
- Demonstration: Be
prepared to explain your code, its logic, and the output to the
instructor.
- Record
Keeping: Maintain a practical journal/file with problem statements,
algorithms/logic, and source code for each practical.
List of Practical Exercises:
Sr. No |
Practical Title |
Key Concepts/Skills Covered |
|
1 |
Broadcast a program to print "Hello
World" on the screen. |
Java Environment & Tools, Writing a Simple
Java Program, System.out.println() |
|
2 |
Implement the Java program to display various * patterns
(e.g., triangle, square, pyramid). |
Control Flow (for, while loops), Nested Loops, Basic Output |
|
3 |
Broadcast the Java program to print the area and
perimeter of a circle. |
Data Types (double, float), Variables, Arithmetic Operators, User Input (Scanner), Math class |
|
4 |
Create a Java program to add two binary numbers. |
User Input, String Manipulation, Loops,
Conditional Statements, Type Conversion (String to int/char),
Basic Logic |
|
5 |
Build a Java program to reverse a string. |
Strings, String Manipulation, Loops, Character
Access (charAt()), StringBuilder/StringBuffer |
|
6 |
Program to count the letters, spaces, numbers,
and other characters in a given string. |
Strings, Loops, Conditional Statements (if-else if),
Character Methods (Character.isLetter(), isDigit(), isSpaceChar()) |
|
7 |
Implement a Java function that calculates the sum
of digits for a given character array representing a number. |
Char Arrays, Loops, Type Conversion (char to int), Arithmetic Operations |
|
8 |
Find the smallest and largest element from an
array of integers. |
1D Arrays, Loops, Conditional Statements, Array
Traversal |
|
9 |
Designed a class that demonstrates the use of
constructors and the object lifecycle. * |
Defining User-Defined Classes, Objects,
Constructors (default, parameterized), this keyword, Object Initialization. |
|
10 |
Program to implement single-level inheritance. |
Inheritance Basics, Superclass, Subclass, super keyword,
Method Overriding |
|
11 |
Project: Develop a small Java application integrating
concepts from Units 1-4. |
Project Planning, OOP Design, Class Design,
Inheritance, Exception Handling, String Manipulation, I/O |
|
*Note on
Practical 9: Constructor and Destructor
In Java,
there is no direct equivalent to a C++ destructor. Java uses automatic garbage
collection to manage memory and reclaim objects that are no longer referenced.
Therefore, this practical will focus on demonstrating:
- How
constructors are used to initialize objects when they are created.
- Understanding
the object’s lifecycle in Java, from creation via new and
constructors, to its eventual eligibility for garbage collection.
- The finalize() method: while present, it’s generally discouraged due to
unpredictable execution and performance overhead, and not considered a
true destructor.
Project Guidelines:
The project
aims to consolidate your understanding of Core Java by developing a simple
application. You will be expected to:
- Identify
a Problem: Choose a small problem that can be solved using Java (e.g., a
simple calculator, a student management system for a few entries , a simple inventory system).
- Design: Plan
your classes, their attributes, and behaviors.
Consider how OOP principles like encapsulation and inheritance can be
applied.
- Implement: Write
well-structured Java code for your application.
- Test: Ensure
your application works as intended and handles various inputs.
- Document:
Provide a brief report explaining your project’s purpose, design choices,
and how to run it.