[go: up one dir, main page]

0% found this document useful (0 votes)
40 views8 pages

Mca Java Syllabus-1

The document outlines the syllabus for the MCA course on Object Oriented Programming using Java, detailing five units covering topics such as Java features, inheritance, exception handling, I/O streams, JDBC, and applets. It includes lab experiments focusing on practical applications of Java concepts, including string manipulation, class design, inheritance, and exception handling. The teaching methods involve various instructional techniques, and references to textbooks and additional reading materials are provided.

Uploaded by

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

Mca Java Syllabus-1

The document outlines the syllabus for the MCA course on Object Oriented Programming using Java, detailing five units covering topics such as Java features, inheritance, exception handling, I/O streams, JDBC, and applets. It includes lab experiments focusing on practical applications of Java concepts, including string manipulation, class design, inheritance, and exception handling. The teaching methods involve various instructional techniques, and references to textbooks and additional reading materials are provided.

Uploaded by

mrdeepakkumar787
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Subject Code Title of the subject L T P C QP

MCA20202 Object Oriented Programming using JAVA 3 0 0 3 A


UNIT-1 (10 Hours)
Introduction to Object-Oriented Paradigm, procedural Paradigm, Features of Java, Data
types, operators & expressions, control structures, Console I/O – reading console input,
writing console output, arrays. Classes, objects & methods, method overloading, constructor
overloading, access qualifiers.
UNIT-2 (10 Hours)
String handling – string operations, character extraction, string comparison, searching and
modifying Strings, StringBuffer, Wrapper classes, Package
Inheritance: single and multilevel inheritance, Inner classes, Interfaces, method overriding,
abstract class, use of super and final keywords.
UNIT-3 (10 Hours)
Exception Handling: Exception types, uncaught exceptions, multiple catch clauses, nested
try statements, built-in exceptions, creating your own exceptions. Multithreading: Java
thread model, creating multiple threads, thread priorities, synchronization, interthread
communication, suspending, resuming, and stopping threads.
UNIT-4 (10 Hours)
I/O Streams: Files I/O – Byte Streams, Character Streams, Collection framework, Applets:
Local & Remote Applets, Applet Architecture, Passing Parameters to Applets, Applet
Graphics, Adapter Class, Event Delegation Model, Java Swing
UNIT-5 (10 Hours)
Basics of JDBC: Introduction to JDBC, Need of JDBC, JDBC Drivers (4 types),
Architecture of JDBC, Components of JDBC (Classes and Interfaces).
Programming with JDBC: Creating a DATABASE (MySQL) , First Program to connect
to the DATABASE created, Loading the Driver, Establishing the Connection, Creating
Statements (Statement/ PreparedStatement/ CallableStatement), Executing a SQL Query,
Different types of SQL Queries.
JDBC Program to retrieve data from DATABASE: Introduction to Result Set, Result Set
with Statement Interface, Result Set with PreparedStatment Interface, Updating and deleting
data in database, ResultSetMetadata, Executing Stored Procedures Using Callable
Statement.
Introduction to Servlet and JSP.
Teaching Methods: Chalk& Board/ PPT/Video Lectures/Lecture by Industry
Expert/MOOCS
Text Books
1. Herbert Schildt, The Complete Reference Java 2, Fourth Edition, Tata McGraw
Hill-2001
2. Liang Y. Daniel, Introduction to Java Programming (7th Edition), 2009, Pearson
Education.
Ref. Books
1. Steven Holzner, Java 1.2, BPB-1998
2. E. Balaguruswami, Programming with Java - Second Edition, Tata McGraw Hill-
1998.
3. Mughal K.A., Rasmussen R.W., A Programmer’s Guide to Java Certification,
Addison-Wesley, 2000 `

Lab Code Name of the Lab L T P C QP


MCA20207 Programming with Java Lab 0 0 2 1
Experiment-1(I/O in Java)
Q 1. Write a Program that accepts two Strings as command line arguments and generate the output in
the required format
Q 2. Write a Java program to find if the given number is prime or not.
Q 3. Write a program to print the sum of all the digits of a given number.
Q 4. Write a Java program to find if the given number is palindrome or not
Q 5. Write a program to print first 5 values which are divisible by 2, 3, and 5.
Experiment 2: (Array)
Q 1. Write a program to initialize an integer array and find the maximum and minimum value of the
array.
Q 2. Write a program to initialize an integer array with values and check if a given number is present
in the array or not.
Q 3. Write a program to find the largest 2 numbers and the smallest 2 numbers in the given array.
Q 4. Write a program to remove the duplicate elements in an array and print the same.
Q 5. Write a program to reverse the elements of a given 2*2 array. Four integer numbers needs to be
passed as Command Line arguments.
Experiment 3:( Class, Object, Static method, Constructor)
Q 1 Create a class Box that uses a parameterized constructor to initialize the dimensions of a box.
The dimensions of the Box are width, height, depth. The class should have a method that can return
the volume of the box. Create an object of the Box class and test the functionalities.
Q 2. Create a new class called Calculator with the following methods:
1. A static method called powerInt(int num1,int num2)
This method should return num1 to the power num2.
2. A static method called powerDouble(double num1,int num2).
This method should return num1 to the power num2.
3. Invoke both the methods and test the functionalities.
Hint: Use Math.pow(double,double) to calculate the power.
Q 3 Design a class that can be used by a health care professional to keep track of a patient’s vital
statistics. The following are the details.
Name of the class - Patient
Member Variables -
patientName(String),height(double),width(double)
Member Function - double computeBMI()
The above method should compute the BMI and return the result. The formula for computation of
BMI is weight (in kg) ÷ height*height(in metres).
Create an object of the Patient class and check the results.
Q 4 Create a class Author with the following information.
Member variables : name (String), email (String), and gender (char)
Parameterized Constructor: To initialize the variables
Create a class Book with the following information.
Member variables : name (String), author (of the class Author you have just created), price (double),
and qtyInStock (int)
[Assumption: Each book will be written by exactly one Author]
Parameterized Constructor: To initialize the variables
Getters and Setters for all the member variables
In the main method, create a book object and print all details of the book (including the author
details)
Experiment 4: (Inheritance and polymorphism)
Q 1. Create a class named ‘Animal’ which includes methods like eat() and sleep(). Create a child class
of Animal named ‘Bird’ and override the parent class methods. Add a new method named fly(). Create
an instance of Animal class and invoke the eat and sleep methods using this object. Create an instance
of Bird class and invoke the eat, sleep and fly methods using this object.
Q 2. Create a class called Person with a member variable name. Save it in a file called Person.java
Create a class called Employee that will inherit the Person class.T he other data members of the
Employee class are annual salary (double), the year the employee started to work, and the national
insurance number which is a String.Save this in a file called Employee.java
Your class should have the necessary constructors and getter/setter methods. Write another class called
TestEmployee, containing a main method to fully test your class definition.
Q 3. Create a school application with a class called Person. Create name and dateOfBirth as member
variables.
Create a class called Teacher that inherits from the Person class. The teacher will have additional
properties like salary, and the subject that the teacher teaches.
Create a class called Student that inherits from Person class. This class will have a member variable
called studentId.
Create a class called College Student that inherits from Student class. This class will have
collegeName, the year in which the student is studying (first/second/third/fourth) etc.
Create objects of each of this classes, invoke and test the methods that are available in these classes.
Q 4. Create a base class Fruit with name ,taste and size as its attributes.
Create a method called eat() which describes the name of the fruit and its taste.
Inherit the same in 2 other classes Apple and Orange and override the eat() method to represent each
fruit taste.
Q 5. Write a program to create a class named shape. It should contain 2 methods, draw() and erase()
that prints “Drawing Shape” and “Erasing Shape” respectively.
For this class, create three sub classes, Circle, Triangle and Square and each class should override the
parent class functions - draw () and erase ().
The draw() method should print “Drawing Circle”, “Drawing Triangle” and “Drawing Square”
respectively.
The erase() method should print “Erasing Circle”, “Erasing Triangle” and “Erasing Square”
respectively.
Create objects of Circle, Triangle and Square in the following way and observe the polymorphic nature
of the class by calling draw() and erase() method using each object.
Shape c=new Circle();
Shape t=new Triangle();
Shape s=new Square();

Experiment 5: (String and StringBuffer)


Q 1. Write a Program to check whether a given String is Palindrome or not.
Q 2. Write a java program that will concatenate 2 strings and return the result. The result should be in
lowercase.
Q 3 Given a string, return a new string made of 'n' copies of the first 2 chars of the original string
where 'n' is the length of the string.
Q 4. Write a java program that will return the first half of the string, if the length of the string is even.
It should return null for odd length string.
Q 5. Write a java program that accepts a string and returns a new string without the first and last
character of the input string.
Q 6. Given 2 strings, a and b, return a new string of the form short+long+short, with the shorter string
on the outside and the longer string on the inside.
Q 7. Given a string, if the first or last chars are 'x', return the string without those 'x' chars, otherwise
return the string unchanged.
Q 8. Write a Java program that accepts a string (with * in it). The program should return a new string
in which the following characters are removed- *,the characters that are to the left and right of *.
Q 9. Given two strings, a and b, print a new string which is made of the following combination-first
character of a, the first character of b, second character of a, second character of b and so on. Any
characters left, will go to the end of the result.
Q 10. Given a string and an integer n, print a new string made of n repetitions of the last n characters
of the string. You may assume that n is between 0 and the length of the string, inclusive.

Experiment 6: (Abstract class and Interface)


Q 1. Create a class called GeneralBank that acts as base class for all banks. This class has
getSavingsInterestRate and getFixedDepositInterestRate methods, which returns the savings account
interest rate and fixed deposit account interest rate that the specific bank gives. Since GeneralBank
cannot say what percentage which bank would give, make these methods abstract.
Create two subclasses of GeneralBank called ICICIBank and KotMBank. Override the inherited
methods from the base class. The following are the interest rates of these banks.
ICICIBank - Savings 4% Fixed 8.5% and
KotMBank - Savings 6% Fixed 9%.
Create a main method to test the above classes and their methods. Try one by one and observe your
findings
a) ICICIBank i=new ICICIBank();
b) KotMBank k=new KotMBank();
c) GeneralBank g=new KotMBank();
d) GeneralBank g=new ICICIBank();
Q 2. Create an abstract class Compartment to represent a rail coach. Provide an abstract function notice
in this class.
public abstract String notice();
Derive FirstClass, Ladies, General, Luggage classes from the compartment class. Override the notice
function in each of them to print notice message that is suitable to the specific type of compartment.
Create a class TestCompartment.Write main function to do the following:
Declare an array of Compartment of size 10.
Create a compartment of a type as decided by a randomly generated integer in the range 1 to 4.
Check the polymorphic behavior of the notice method. [i.e based on the random number genererated,
the first compartment can be Luggage, the second one could be Ladies and so on..]
Q 3. Create an abstract class Instrument which is having the abstract function play.
Create three more sub classes from Instrument which is Piano, Flute, Guitar. Override the play
method inside all three classes printing a message
“Piano is playing tan tan tan tan ” for Piano class
“Flute is playing toot toot toot toot” for Flute class
“Guitar is playing tin tin tin ” for Guitar class
Create an array of 10 Instruments. Assign different type of instrument to Instrument
reference.
Check for the polymorphic behavior of play method.
Use the instanceof operator to print which object is stored at which index of instrument array.

Q 4. Write an interface called Playable, with a method void play();


Let this interface be placed in a package called music.
Write a class called Veena which implements Playable interface. Let this class be placed in a package
music.string
Write a class called Saxophone which implements Playable interface. Let this class be placed in a
package music.wind
Write another class Test in a package called live. Then,
a. Create an instance of Veena and call play() method
b. Create an instance of Saxophone and call play() method
c. Place the above instances in a variable of type Playable and then call play()

Experiment 7 : (Exception Handling)


Q 1. Get an input String from user and parse it to integer, if it is not a number it will throw number
format exception Catch it and print "Entered input is not a valid format for an integer." or else print the
square of that number. (Refer Sample Input and Output).
Q 2. Write a program that takes as input the size of the array and the elements in the array. The program
then asks the user to enter a particular index and prints the element at that index.
This program may generate Array Index Out Of Bounds Exception. Use exception handling
mechanisms to handle this exception. In the catch block, print the class name of the exception thrown.
Q 3. Write a program that takes as input the size of the array and the elements in the array. The program
then asks the user to enter a particular index and prints the element at that index. Index starts from zero.
This program may generate Array Index Out Of Bounds Exception or NumberFormatException . Use
exception handling mechanisms to handle this exception.
Q 4. Write a program to accept name and age of a person from the command prompt(passed as
arguments when you execute the class) and ensure that the age entered is >=18 and < 60. Display
proper error messages.
Q 5. A student portal provides user to register their profile. During registration the system needs to
validate the user should be located in India. If not the system should throw an exception.
Step 1: Create a user defined exception class named “InvalidCountryException”.
Step 2: Overload the respective constructors.
Step 3: Create a main class “UserRegistration”, add the following method,
void registerUser(String username,String userCountry) with the below implementation
• if userCountry is not equal to “India” throw a InvalidCountryException with the message “User
Outside India cannot be registered”
• if userCountry is equal to “India”, print the message “User registration done successfully”
Invoke the method registerUser from the main method with the data specified and see how the program
behaves.
Q 6. Write a Program to take care of Number Format Exception if user enters values other than integer
for calculating average marks of 2 students. The name of the students and marks in 3 subjects are taken
from the user while executing the program.
In the same Program write your own Exception classes to take care of Negative values and values out
of range (i.e. other than in the range of 0-100)

Experiment-8 : (Wrapper class and file handling)


Q 1. Write a program to receive an integer number as a command line argument, and print the binary,
octal and hexadecimal equivalent of the given number.
Q 2. Write a Java program that reads an integer number (between 1 and 255) from the user and prints
the binary representation of the number. The answer should be printed as a String.
Q 3. Create an employee class with properties of your choice. Create an object of this class and also
create a clone of the same. After making the clone, change the properties of the original employee
object and print the properties of both the original and clone object and note down your observation.
Q 4. Write a program to count the number of times a character appears in a File.
Q 5. Write a program to copy contents from one file to another and check the output.
Q 6. Write a program to count the occurrences of each word in an input file and write the word along
with its corresponding count in an output file.
Q 7. Create a class called Employee with properties name(String), dateOfBirth (java.util.Date),
department(String), designation(String) and Salary(double).
Create respective getter and setter methods and constructors (no-argument constructor and
parameterized constructor) for the same.
Create an object of the Employee class and save this object in a file called "data" using serialization.
Later using deserialization read this object and print the properties of this object.

Experiment-9 (Collection Framework)


Q 1. Write a Java program to create an ArrayList, add all the months of a year and print the same.
Q 2. 1) Create an application for employee management with the following classes:
a) Create an Employee class with following attributes and behaviors :
i) int empId
ii)String empName
iii)String email
iv)String gender
v)float salary
vi) void GetEmployeeDetails() -> prints employee details
b) Create one more class EmployeeDB with the following attributes and behaviors.
(i)ArrayList list;
ii) boolean addEmployee(Employee e) -> adds the employee object to the collection
iii) boolean deleteEmployee(int empId) ->delete the employee object from the collection with the given
empid
iv) String showPaySlip(int empId) -> returns the payslip of the employee with the given empId
Provide implementation for all the methods and test your program.
Q 3. Develop a java class with a instance variable H1 (HashSet) add a method
saveCountryNames(String CountryName) , the method should add the passed country to a HashSet
(H1) and return the added HashSet(H1).
Develop a method getCountry(String CountryName) which iterates through the HashSet and returns
the country if exist else return null.
NOTE: You can test the methods using a main method.
Q 4. Create a Collection called TreeSet which is capable of storing String objects. Then try these
following operations :
a) Reverse the elements of the Collection.
b) Iterate the elements of the TreeSet using Iterator.
c) Check if a particular element exists or not.
Q5. 1. Develop a java class with a instance variable M1 (HashMap) create a method
saveCountryCapital(String CountryName, String capital) , the method should add the passed country
and capital as key/value in the map M1 and return the Map (M1).
Key- Country Value - Capital
India Delhi
Japan Tokyo
2. Develop a method getCapital(String CountryName) which returns the capital for the country passed,
from the Map M1 created in step 1.
3. Develop a method getCountry(String capitalName) which returns the country for the capital name,
passed from the Map M1 created in step 1.
4. Develop a method which iterates through the map M1 and creates another map M2 with Capital as
the key and value as Country and returns the Map M2.
Key – Capital Value – Country
Delhi India
Tokyo Japan
5. Develop a method which iterates through the map M1 and creates an ArrayList with all the Country
names stored as keys. This method should return the ArrayList.
NOTE: You can test the methods using a main method.
Q 59. Create a Collection “ContactList” using HashMap to store name and phone number of contacts
added. The program should use appropriate generics (String, Integer) and have the following abilities:
a) Check if a particular key exists or not.
b) Check if a particular value exists or not.
c) Use Iterator to loop through the map.

Experiment 10: (Swing)


Q 1. Write a java program to create a frame containing three buttons (Yes, No, Close). When button
yes or no is pressed, the message "Button Yes/No is pressed" gets displayed in label control. On
pressing CLOSE button frame window gets closed.
Q 2. Write a Java program to create three radio buttons. When any of them is selected, an appropriate
message is displayed.
Q 3. Write a Java program to create a combo box which includes list of subjects. Display the selected
subject in the text field using Swing.
Q 4. Write a java program using swing to create a frame having three text fields. Accept number in
first textfield and display previous number in second textfield and next number in the third textfield.
Q 5. Write a program to display "All The Best" in 5 different colors on screen. (Using AWT/Swing)
Experiment 11: (JDBC with MySQL)
Q 1. Write a java program that connects to oracle/MySQL database, queries the inbuilt table “emp”
and displays the first two columns (empno using column index and ename using column name ) of all
the rows.
Q 2. Develop a jdbc program containing main method, which should instantiate a class called
DAOClass, which should contain methods called insert, delete, modify and display. Description of
what each of these methods are expected to do is given below.
Necessary details required for executing these methods, are passed from command line argument.
For e.g. If the name of the class containing the main method is JDBCCalls, then if you want to insert
a record, you will execute this class as java JDBCCalls 1 101 “Ajit” “IV” “20-Nov-2001” 4000
Where 1 is the option for inserting the record and all other details are the values for the columns in
each row of the student table. The structure of student table is given below. Similarly, for deleting a
record, you have to execute the code as java JDBCCalls 2 101
where 2 is the option for deleting a record and 101 is the rollno of the student, whose record has to be
deleted.
For modifying a record, you will use java JDBCCalls 3 101 4500, where 3 is the option for
modifying a record and the 4500 is the new fee which needs to replace the old fee value.
For Displaying records, if the main class is executed as follows
java JDBCCalls 4 101
it should display only one record, that of the student with roll no. 101. 4 option is for displaying the
record. If the main class is executed as java JDBCCalls 4 (without specifying the rollno.), it means
that details of all the students should be displayed.

You might also like