QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:gabrielmusyoka940@gmail.com
, lOMoARcPSD|31863004
Lab Exercises
Object Oriented Programming with Java
Lab Exercise
Lab Unit – 1 (2 Hrs actual Time)
1.1 Write a program to display any message:
1.2 Write a Java program to display default value of all primitive data types of
Java.
1.3 Write a program check two strings are equal or not.
Lab Unit – 2 (2 Hrs actual
Time)
2.1 Write a program to give the examples of operators.
2.2 Write a program to give the example of control statements.
2.2.1 If statements.
2.2.2 Switch Statements.
2.2.3 For loop.
2.2.4 While Statements.
2.2.5 Do statements
2.3 Write a program to calculate the following
2.3.1 Find the length of array.
2.3.2 Demonstrate a one-dimensional array.
2.3.3 Demonstrate a two-dimensional array.
2.3.4 Demonstrate a multi-dimensional array.
2.4 Write a program give example for command line arguments.
Centre for Information Technology and Engineering, Manonmaniam Sundaranar University 1
, lOMoARcPSD|31863004
Object Oriented Programming with Java
2.4.1 To find the sum of command line arguments and count the
invalid integers entered.
2.4.2 To get the name using command line.
2.5 Write a program to print the following triangle of binary digits.
2.7 Write a program to arrange the numbers in ascending order.
2.8 Write a program to calculate the roots of Quadratic equations.
2.9 Write a program for calculating Matrix Operations.
2.9.1 Addition.
2.9.2 Multiplication.
Lab Unit – 3 (2 Hrs Real Time)
3.1 Write a program to create a room class, the attributes of this class is
roomno, roomtype, roomarea and ACmachine. In this class the member
functions are setdata and displaydata.
2 Centre for Information Technology and Engineering, Manonmaniam Sundaranar University
Downloaded by Gabriel Musyoka (gabrielmusyoka940@gmail.com)
, lOMoARcPSD|31863004
Lab Exercises
3.2 Write a program create a class ‘simpleobject‘. Using constructor display
the message.
3.3 Write a program for the following
1. Example for call by value.
2. Example for call by reference.
3.4 Write a program to give the example for ‘this’ operator. And also use the
‘this’ keyword as return statement.
Lab – 4 (2 Hrs Real Time)
4.1 Write a program to demonstrate static variables, methods, and blocks.
4.2 Write a program for reuse class. For this program use the above ‘room
class’ program.
4.3 Create class named as ‘a’ and create a sub class ‘b’. Which is extends from
class ‘a’. And use these classes in ‘inherit’ class.
4.4 Write a program to give the example for method overriding concepts.
4.5 Write a program to give the example for ‘super’ keyword.
Lab – 5 (2 Hrs Real Time)
5.1 Write a program to create a class named shape. In this class we have three
sub classes circle, triangle and square each class has two member function
named draw () and erase (). Create these using polymorphism concepts.
5.2 Write a program to give a simple example for abstract class.
5.3 Write a program suppose, it is required to build a project consisting of a
number of classes, possibly using a large number of programmers. It is
necessary to make sure that every class from which all other classes in the
project will be inherited. Since any new classes in the project must inherit
from the base class, programmers are not free to create a different
interface. Therefore, it can be guaranteed that all the classes in the project
will respond to the same debugging commands.
Centre for Information Technology and Engineering, Manonmaniam Sundaranar University 3
Downloaded by Gabriel Musyoka (gabrielmusyoka940@gmail.com)
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying this summary from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller gabrielmusyoka940. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy this summary for R46,75. You're not tied to anything after your purchase.