Sei sulla pagina 1di 5

R.K.

College of Engineering & Technology


Kasturbadham Rajkot 36002
Semester: B.E. SEM V
Subject: Object Oriented Programming with Java
Practical List

TOTORIAL:-1

1. Write a java application to display user’s name on the screen

2. Write a java application that declares one integer variable called num.Give this variable the value
1000 and then ,using one println() method to display the value on the screen like this

1000 is the value of num

3. Write a java application that displays a string with an embedded quote for example :-

Juliet said: “ Romeo ,where are you?”.

4. Write a java application that create a string variable called myname:-using concatenation,assign
the variable first and last name,use one string literal for your first name and another for your last
name.

5. Write a java application that creates and initialize a four element int array,calculate and display
the average of its values.

TOTORIAL:-2

1. Write a program that displays the square root of 24.45

2. Write a java application that displays the substring formed by the last ten characters of a string.

3. A string contains five numbers separated by commas. Write a java application that displays the
last number

4. Write a java application that displays the hex equivalent of an int.

5. Write a java application that creates two integer objects by using the different constructors .use
the instance method named equals() to test if they represent the same value.
TOTORIAL:-3

1. create a string buffer object and illustrates how to append character .display the capacity and
legth of the string buffer.

2. Create a String buffer object and illustrates how to insert characters at its beginning.

3. Create a String buffer object and illustrates the operation of the append() and reverse()
methods

4. Write a java application to count the factorial of number Enter through command line
argument.\

5. Write a java application tha displays all numbers between 20 and 30.Use a for loop and the
increment operator.

6. Write a java application that counts the number of vowels in the string specified as a
command line argument.

7. Write a java application that accepts several command-line argument, converts each of these
to a number, and adds these numbers together.use a while loop to iterate through the
command-line arguments.

TOTORIAL:-4

1. Write an application that declares a class named person.It should have instance variables
name,age and salary.these should be of type string, int and float.use the new operator to
create a person objest set and display its value.

2. Write a java application that implements constructor overloading.

3. Write a java application that implements method overloading

4. Write an application that illustrates how a method can invoke a super class method. Class I2
is extended by class J2 . Class J2 is extended by class K2 each of these classes defines a get
description() method that returns a string includes a description of the class plus description
of each superclass. Instantiate each of these classes and invoke the getdescription() mehod

5. The abstract class shape has three subclasses Circle, Triangle& Rectangle. Write a java
application that calculates the area for each shape object .Use method overriding.
TOTORIAL:-5

1. Write a java application that illustrates interface inheritance.

2. The abstract class Tent has concrete subclasses named TentA, TentB, TentC, TentD.The
Waterproof interface defines no constants and declares no methods.It is implemented by
TentB and TentD. Define all classes and implement the interface as specified .Create one
instance of each class.Then display all waterproof tents.place this code in a package named
tents.

3. Write a program that illustrates how to use the throw statement create a class that has static
methods main ( ), A ( ), B ( ), C ( ), And D ( ). The main method invokes A ( ). Method A ( )

invokes B ( ). Method B ( ) invokes C ( ). Method C ( ) invokes D ( ). Method D ( )


declares a local array with ten elements and then attempts to access the element at position
20.Therefore, an ArrayIndexOutOfBoundsException is generated. Each method has a catch
block for this type of exception and a finally block. The catch blocks in C ( ) and D ( )
contain a throw statement to propagate this exception to their caller. Use the println ( )
method to monitor the flow of control in your program.

4. A method named add() accepts an array of strings as its argument.It converts these to double
values and return their sum.The method generates a NumerFormatException if an element is
incorrectly formatted.It can also create and throw a custom exception rangeException if an
element is less than 0 or greater than 1. Write a java application that illustrates how to
declare and use this method.Also, provide a finally clause to thank the user for using this
program.

TOTORIAL:6

1. Write a java application to create two thread.The thread class displays a string every second for
10 iterations.The thread class display a string every two seconds for 20 iterations.The main()
method of joindemo creates two thread by extending the thread class.

2. Write an application that executes two threads. One thread Displays “ A “ every 1,000
milliseconds. And the other displays “ B “ every 3,000 milliseconds. Create the threads by
implementing the runnable interface.

3. .Write an applet to draw a line between two point in the applet display area.

4. Write an applet to draw a polygon

5. Write an applet that displays an image.


TOTORIAL:7

1. Write an applet in which creates a solid circle that moves from left to right across the applet display
area .( use double buffering)

2 .Write an applet to receive mouseEvent, Implement the


mouseClicked(),MouseEnetred(),mouseExited(),mousepressed(),mouseReleased() method in that just set
the different background color ( Note: it is necessary to call repaint() to refresh the display so the color
change becomes visible.)

3.Use anonymous inner classes to write an applet that chages to background red while the mouse is being
pressed and green while the mouse is being Released.At all other ,the appet should be white.

TOTORIAL:8

1.Write an applet that contains one button.Intialize the label on the button to “start” .When the user
presses the button, change the label to “stop”. Toggle the button label between these two values each time
the button is pressed.

2.Write an applet that contains a check box group with there check box es labeled “red” , “green”, and
“blue”.There is also a 30* 30 pixel canvas.The selection of the check boes determines the color os the
canvas.

3.Write an applet to copy the text from one text field to another text field.

4. Write an applet to create a simple menu.

5. Write an applet to create a File Dialog Box.


TOTORIAL:9

1. Write an application that reads a file and counts the number of occurrences of each digit
between ‘0’ to ‘9’. Supplt the file name as a command line argument.

2. Write an application that reads and process strings from the console. Reverse the sequence of

Character in each string and then display it.

3. Write one application that write the first 15 numbers of the Fibonacci series to a file. Use the

writeShort() method of DataOutputStream to output the numbers.Write a second application

that reads this data from a file and display it. Use the readShort() method of dataInputStream

to input the numbers.For both applications, specify the name of the file as a command line

argument.

4.Write a program to display the bytes of a file in reverse sequence .Provide the name of the file

as a command line argument.

Potrebbero piacerti anche