Sunteți pe pagina 1din 3

Om Shanti Engineering College, Bedi, Rajkot

Department : Information Technology


Semester : BEIT – 3rd Semester
Subject : OO Programming with Java
Subject Code : 150704

Assignment-1
(1) Enlist the benefits of Java Language.
(2) Enlist and explain the basic concepts/characteristics of Object Oriented Programming.
(3) What are the elements of Object Oriented Approach?
(4) What are the significances of PATH and CLASSPATH environment variables?
(5) Write a simple java program that finds the sum of two integer numbers. Write down
commands or steps to compile and run this java program.
(6) What is package? Write benefits of using packages in Java. Write commands or steps
to compile and run the java program with package statement.
(7) What is the structure of the Java file?

Assignment-2
(1) Write a Java program that checks whether the give integer number is even or odd.
(2) Given 3 integer numbers, write a java program that finds out maximum number.
(3) Write a java program that accepts principal amount (p), rate of interest (I) and number
of years(n) from the keyboard. Write a function that calculates simple interest based
on these given criteria. I=PRN/100.
(4) Write a java program to find the sum of all digits of a given number. For example, if
the given number is 12345 the sum of the digits is 1 + 2 + 3 + 4 + 5=15.
(5) Write a Java program that accepts 2 integer numbers from the user. Based on the
user’s choice the program would perform the following operations.
1: Sum
2: Difference
3: Multiplication
4: Division

Mukesh D. Parsana (Assistant Professor, BEIT, Om Shanti Engineering College,


Rajkot)
Assignment-3
(1) Write a short note on Basic Data Types available in Java.

(2) What is identifier? Write the rules for identifiers in Java. Which of the following are
valid identifiers in Java?
FLOAT _abc$ class main 1float_
intfloat $$$$ _om_ Public Abc420

(3) What is Type casting? Explain Implicit and Explicit type casting with suitable
examples. In which situations type casting might be required?

(4) Explain 3 types of variables available in Java. (Local, Instance/Object level and class
level variables).

(5) Check whether the following statements are true/false.


a. Static method can be called without creating object of the class.
b. Static method can not be called using object of the class.
c. There can be more then one public classes in a java file.
d. If the signature of the main method in a class is public void main(String
args[]), compiler will show compile time error.
e. All the integer data types available in java are signed data type.

(6) Write a java program which finds roots of the quadratic equation ax + bx + c = 0
2

−b ± b 2 − 4 ac
Roots =
2a
(Use static method sqrt() defined in Math class of java.lang package)

(7) Write a static method factorial() which calculates factorial of a given number.
(Use recursive function)

(8) Write java classes Circle and Rectangle which will have methods related to
calculating area and perimeter of circle and rectangle. Class Circle must be defined
within package “com.circle” and class Rectangle must be defined with package
“com.rectangle”. Accept appropriate inputs from the keyboard and use these classes
in Testclass which will display area and perimeter for the given user inputs.

(9) Write a java function for banking application which will have 3 functions:
balanceInquiry(), deposit() and withdraw(). Program must react as per the following
choices of the user: 1 = balace inquiry, 2 = deposit, 3=withdraw, 4=exit

Mukesh D. Parsana (Assistant Professor, BEIT, Om Shanti Engineering College,


Rajkot)
Assignment-4
(1) Write a simple java program which calculates sum of all 10 elements of an one
dimension array. Write a java function input which will receive and return an one
dimension array.
(2) Write a java program which sorts 10 given integer elements of a one dimension array.
(3) Write a java program which displays given integer number in reverse order. i.e. if
given integer number is 12345 then output would be 54321.
(4) Write a java program which calculates multiplication of two 3*3 matrices.
(5) Update banking application program written in assignment 3 to display transaction
statement in details. i.e. type of transaction and amount of transaction. Use
appropriate array to maintain transaction statement.

Sample transaction statement:


Initial Balance: 5000
Deposit: 2000
Credit: 1000
Deposit: 3000
Credit: 4000
Final Balance: 5000

Program must react as per the following choices of the user:


1 = balance inquiry
2 = deposit money
3=withdraw or credit money
4=view transaction statement
5=exit.

Assignment-5
(1) Write a program that accepts three integer values as command line arguments add
those together and display the answer.
(2) Write a program that creates class Student with private data members name (String),
Age (int), Gender (char) and Percentage (double). Initialize data members using
constructor overloading. Provide 1 argument, 2 arguments, 3 arguments and no
argument constructors. Write appropriate getter and setter methods. Display values of
data members using print() function. Use getter and setter methods to change values
of data members.
(3) Write a Super class “Animal” having eat () and sleep () methods. Write two
subclasses of this class named “Bird” and “Pet”. Bird class will have additional fly ()
method and Pet class will have additional run () method. Create the objects of Animal,
Bird and Pet classes and try to call appropriate methods.

Mukesh D. Parsana (Assistant Professor, BEIT, Om Shanti Engineering College,


Rajkot)

S-ar putea să vă placă și