SlideShare a Scribd company logo
L.D. College of Engineering
SEM: 5th Information Technology
Subject: JAVA Programming
                                      Practical List

1    Pass student name using command line argument and print output in following
     format: First Name : abc
                Second Name : pqr
                Last Name : str
2    Write a program that creates and initializes a four element byte array. Calculate and
     display the average of its values.
3.   Write an application that creates a two-dimension arrary with int values. the first,
     second, and third elements should be arrays with one, two and three numbers
     respectively. Display the length of each dimension.
4    Write a program to check whether given number is even or odd.
5    Write a program that displays the value of 2 raised to the power 12.
6.   Write a program that displays the substring formed by the last ten characters of a
     string.(Use length() method)
7    A string contains five numbers separated by commas .Write a program that displays
     the last number.
9    Write a program check primality of a number.
10   Write a program to create circle class with area function to find area of circle.
11   Define class complex with function to add and to compare to complex number.
12   Write a program to print following triangle with character ‘A’ passed as command
     line argument for n row.
     A AAA
     A AA
     AA
     A
13   Create circle class then derive cylinder class with overriding of area calculation
     method.
14   Create Tiles class with lengh and width parameter and area calculation methos.Derive
     subclass Room with same parameter and quantity function to calculate number of
     tiles required as per room size.
15   Write a program to find volume of Box. Overload constructor to initialize data
     member of Box. Derive class BoxWeight with weight data member and density
     calculation method.
16   Derive shipment class form above BoxWeight class with data member shipping price
     per unit weight and calculate method to find total shipping cost.
17   Create a StringBuffer object and illustrate the operation of the append() and reverse()
     methods.
18   Write an application that creates an array with five Float arguments and display the
     length of the array and its elements.
19   Write an application that accepts two doubles as its command-line arguments,
     multiplies these together, and display the product.
20   Write an application that converts between meters and feet.its first command-line
     argument is a number. Its second command-line argument if either “feet” or
     “meters”. If this argument equal “feet”, display a string reporting the equivalent
     number of meters. If this argument equal “meters”, display a string reporting the
     equivalent number of feet. Otherwise, report that the unit system is not recognized.
(note: one meter is equal to 3.28 feet.)
21 Write a program that outputs a table of numbers. Each line in the table contains three
   entries: the number, its square, and its cube. Begin with 1 and end with 10.
22 Use While loop to generate random numbers and maintain a running sum of these
   values. Terminate when the sum exceeds 20. (Note: use Math. random() method to
   obtain numbers.)
23 Write an application that generates the first 15 numbers in the Fibonacci series.
24 Write an application that counts the total number of characters in all of its command-
   line arguments.
25 Write an application that searches through its command-line argument. If an
   argument is found that does not begin with and upper case letter, display error
   message and terminate.
26 Write an application that declares a class named Sphere. It should have instance
   variables to record its radius and the coordinates of its center. This should be of type
   double. Use the new operator to create a Sphere object. Set and display its instance
   variables.
27 Write an application that defines a Circle class with two constructors. The first form
   accepts a double value that represents the radius of the circle. This constructor
   assumes that the circle is centered at the origin. The second form accepts the three
   double values. The first two arguments define the coordinates of the center and the
   third argument defines the radius.
28 Write an application that defines a sphere class with three constructors.
   The first form accepts no arguments. It assumes the sphere is centered at the origin
   and has a radius of one unit. The second form accepts one double value that
   represents the radius of the sphere. It assumes the sphere is centered at the origin .The
   third form accept four double arguments. These specify the coordinates of the center
   and the radius.
29 Write an application that demonstrates a class inheritance hierarchy. Class M extends
   Object and has two instance variable of type float and String. Class N extends M and
   has one instance variable of type Double. Instance class N initialize and display its
   variables.
30 Write a program that illustrates method overriding. Class Bond is extended by
   ConvertibleBond. Each of there classes defines a display() method that outputs the
   string “Bond” of “ConvertibleBond”, respectively. Declare an array to hold six Bond
   objects. Initialize the elements of the array with a mix of Bond and ConvertibleBond
   objects. Execute a program loop to invoke the display method of each object.
31 Write an application that illustrates how a method can invoke a superclass method.
   Class I2 is extended by J2.Class J2 is extended by K2.Each of these classes defines a
   getDescription() method that returns a string. That string includes a description of the
   class plus descriptions of each superclass. Instantiate each of these classes and invoke
   the getDescription() method.
32 Write a program that illustrates interface inheritance. Interface p is extended by P1
   and P2.Interface p12 inherits from both P1 and P2.Each interface declares one
   constant and one method. Class Q implements P12.Instatiate Q and invoke each of its
   methods. Each method Displays one of the constants.
33 Assume that you created three packages named a.b.c.d, j.k.l.m, and r.s.t. the .class
   files for these packages are stored in directories c:lab8abc, c:freshmanchem101j
   klm,and c:semeinarrst,respectively.How should CLASSPATH be set so the
   classes and interfaces in those three packages can be located by JDK tools.
34 Write a program that illustrates how to use the throw statement. Create a class that
has static method 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.Therefor,and ArryIndexOutOfBound Exception 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.

35 A method named average() has one argument that is an array of strings. It converts
   these to double values and returns their average. The method generates a
   NullPointerException if a array elements is null or NumberFormatException if an
   element is incorrectly formatted. Write a program that illustrates how to declare and
   use this method. Include throws clause in the method declaration to indicate that
   these problems can occur.
36 Write an application that reads a file and counts the number of occurrences of each
   digit between 0 and 9 .supply the file name as a command-line argument.
37 Write an application that reads and processes strings from the console. Reverse the
   sequence of characters in each string and then display it.
38 Write one application that writes the first 15 numbers of the Fibonacci series to a file.
   Use writeSort() method of DataOutputStrem to output the numbers. Write a second
   application that reads this data from a file and displays it. Use the readShort() method
   of DataInputStream to input the numbers. For both applications ,specify the name of
   the file a command-line argument.
39 Write an Applet which display one string named LDCE at the centre in red color.
40 Write an applet that draws a circle. The dimensions of the applet should be 500*300
   pixels. The circle should be centered in the applet and have radius of 100 pixels.(Use
   the drawOval() method of Graphics.)
41 Write an applet that draws a rectangle and display one string in the center of the
   rectangle with yellow color. Also fill rectangle with blue color. The dimension of
   applet should be 500*300 pixels.
42 Write an applet which insets an image.
43 Write an applet that tracks the position of the mouse when it is dragged or moved.
   Draw a 10 * 10 pixel rectangle filled with black at the current mouse position.
44 Write an applet that contains one button. Initialize 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.
45 Write an applet and frame program that tracks the position of the mouse when it is
   dragged or moved. Print “hello” at the current mouse position.
46 Write an applet that contains three check boxes and 30 * 30 pixel canvas. The three
   check boxes should be labeled “red” ,”Green” and “Blue” .The selections of the
   check boxes determine the color of the canvas. for example ,if the user selects both
   “Red” and “Blue” the canvas should be purple.(Hint: Use the setBackground() and
   repaint() ,methods to change the color of the canvas)
47 Write a java frame program when mouse pressed in frame area ,each time new button
   added to frame. Write same program with different layout and see output.
48 Write a java frame program when mouse pressed in frame area new window is
   opened.When close button is pressed only one window should be closed.
49 Write a java frame program which shows use of button, menu bar and menu item.
50 Write an applet that contains one choice element and a 30 * 30 pixel canvas. The
   items in the choice element should be “red”, ”Green” and “Blue”. The Choice
selection should determine the color of the canvas.
51 Write a program to display a random integer between 5 and 10 every three seconds.
52 Write a multithreaded program that simulates a set of grasshoppers jumping around
   in a box. Each grasshopper jumps to a different location every 2 to 12 seconds.
   Display the new location of a grasshopper after each of these jumps.
53 Write a multi thread java program to find factorial of a large number.

More Related Content

RTF
Cse cpl manual-2016
PDF
I PUC CS Lab_programs
PDF
Mmt 001
DOCX
Ecet 370 week 1 lab
DOC
Paper
PDF
Intake 38 6
DOC
Data structures question paper anna university
Cse cpl manual-2016
I PUC CS Lab_programs
Mmt 001
Ecet 370 week 1 lab
Paper
Intake 38 6
Data structures question paper anna university

What's hot (20)

PDF
CP Handout#7
DOC
Sp 1418794917
PDF
Computer science sqp
PPS
C programming session 04
PDF
Intake 38 4
PDF
R Programming: Introduction to Vectors
PPS
C programming session 02
PDF
Java conceptual learning material
PDF
Numerical analysis using Scilab: Numerical stability and conditioning
PDF
Intake 38 3
PDF
Numerical analysis using Scilab: Error analysis and propagation
PDF
PDF
BPstudy sklearn 20180925
PPT
Unit 2 c programming_basics
PDF
Numerical analysis using Scilab: Solving nonlinear equations
PPT
Unit 4 functions and pointers
PPT
Unit 3 arrays and_string
PDF
CP Handout#4
PPTX
CP Handout#7
Sp 1418794917
Computer science sqp
C programming session 04
Intake 38 4
R Programming: Introduction to Vectors
C programming session 02
Java conceptual learning material
Numerical analysis using Scilab: Numerical stability and conditioning
Intake 38 3
Numerical analysis using Scilab: Error analysis and propagation
BPstudy sklearn 20180925
Unit 2 c programming_basics
Numerical analysis using Scilab: Solving nonlinear equations
Unit 4 functions and pointers
Unit 3 arrays and_string
CP Handout#4
Ad

Viewers also liked (7)

DOC
List of programs for practical file
PDF
Bca sem 6 php practicals 1to12
DOC
Advanced Java - Praticals
PDF
Advanced java practical semester 6_computer science
PDF
tybsc it asp.net full unit 1,2,3,4,5,6 notes
DOC
Ad java prac sol set
PDF
Advanced Java Practical File
List of programs for practical file
Bca sem 6 php practicals 1to12
Advanced Java - Praticals
Advanced java practical semester 6_computer science
tybsc it asp.net full unit 1,2,3,4,5,6 notes
Ad java prac sol set
Advanced Java Practical File
Ad

Similar to Practical java (20)

PDF
Lab exam question_paper
DOCX
JAVA practical Exam Questions (1).docx
DOCX
Chapter 8Exercise1.Design an application that accept.docx
PDF
Ee java lab assignment 3
DOCX
Lab exam question_paper
PDF
Object oriented programming -QuestionBank
PDF
Java practical(baca sem v)
DOC
Course Breakup Plan- C
DOCX
Oop lab assignment 01
DOCX
Java codes
DOC
Java final lab
DOC
Report in Java programming and SQL
DOC
Java programming lab assignments
PDF
66781291 java-lab-manual
DOCX
Ee java lab assignment 3
PDF
Java practical N Scheme Diploma in Computer Engineering
DOC
CS2309 JAVA LAB MANUAL
PPTX
Java basics
DOCX
Java practical
PDF
Cs8261 cp lab syllabus
Lab exam question_paper
JAVA practical Exam Questions (1).docx
Chapter 8Exercise1.Design an application that accept.docx
Ee java lab assignment 3
Lab exam question_paper
Object oriented programming -QuestionBank
Java practical(baca sem v)
Course Breakup Plan- C
Oop lab assignment 01
Java codes
Java final lab
Report in Java programming and SQL
Java programming lab assignments
66781291 java-lab-manual
Ee java lab assignment 3
Java practical N Scheme Diploma in Computer Engineering
CS2309 JAVA LAB MANUAL
Java basics
Java practical
Cs8261 cp lab syllabus

Recently uploaded (20)

PDF
Sports Quiz easy sports quiz sports quiz
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Insiders guide to clinical Medicine.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
RMMM.pdf make it easy to upload and study
PPTX
Pharma ospi slides which help in ospi learning
PDF
Classroom Observation Tools for Teachers
PPTX
Lesson notes of climatology university.
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Pre independence Education in Inndia.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
Sports Quiz easy sports quiz sports quiz
102 student loan defaulters named and shamed – Is someone you know on the list?
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Complications of Minimal Access Surgery at WLH
Insiders guide to clinical Medicine.pdf
VCE English Exam - Section C Student Revision Booklet
RMMM.pdf make it easy to upload and study
Pharma ospi slides which help in ospi learning
Classroom Observation Tools for Teachers
Lesson notes of climatology university.
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Pre independence Education in Inndia.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPH.pptx obstetrics and gynecology in nursing
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
human mycosis Human fungal infections are called human mycosis..pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
O7-L3 Supply Chain Operations - ICLT Program
Renaissance Architecture: A Journey from Faith to Humanism

Practical java

  • 1. L.D. College of Engineering SEM: 5th Information Technology Subject: JAVA Programming Practical List 1 Pass student name using command line argument and print output in following format: First Name : abc Second Name : pqr Last Name : str 2 Write a program that creates and initializes a four element byte array. Calculate and display the average of its values. 3. Write an application that creates a two-dimension arrary with int values. the first, second, and third elements should be arrays with one, two and three numbers respectively. Display the length of each dimension. 4 Write a program to check whether given number is even or odd. 5 Write a program that displays the value of 2 raised to the power 12. 6. Write a program that displays the substring formed by the last ten characters of a string.(Use length() method) 7 A string contains five numbers separated by commas .Write a program that displays the last number. 9 Write a program check primality of a number. 10 Write a program to create circle class with area function to find area of circle. 11 Define class complex with function to add and to compare to complex number. 12 Write a program to print following triangle with character ‘A’ passed as command line argument for n row. A AAA A AA AA A 13 Create circle class then derive cylinder class with overriding of area calculation method. 14 Create Tiles class with lengh and width parameter and area calculation methos.Derive subclass Room with same parameter and quantity function to calculate number of tiles required as per room size. 15 Write a program to find volume of Box. Overload constructor to initialize data member of Box. Derive class BoxWeight with weight data member and density calculation method. 16 Derive shipment class form above BoxWeight class with data member shipping price per unit weight and calculate method to find total shipping cost. 17 Create a StringBuffer object and illustrate the operation of the append() and reverse() methods. 18 Write an application that creates an array with five Float arguments and display the length of the array and its elements. 19 Write an application that accepts two doubles as its command-line arguments, multiplies these together, and display the product. 20 Write an application that converts between meters and feet.its first command-line argument is a number. Its second command-line argument if either “feet” or “meters”. If this argument equal “feet”, display a string reporting the equivalent number of meters. If this argument equal “meters”, display a string reporting the equivalent number of feet. Otherwise, report that the unit system is not recognized.
  • 2. (note: one meter is equal to 3.28 feet.) 21 Write a program that outputs a table of numbers. Each line in the table contains three entries: the number, its square, and its cube. Begin with 1 and end with 10. 22 Use While loop to generate random numbers and maintain a running sum of these values. Terminate when the sum exceeds 20. (Note: use Math. random() method to obtain numbers.) 23 Write an application that generates the first 15 numbers in the Fibonacci series. 24 Write an application that counts the total number of characters in all of its command- line arguments. 25 Write an application that searches through its command-line argument. If an argument is found that does not begin with and upper case letter, display error message and terminate. 26 Write an application that declares a class named Sphere. It should have instance variables to record its radius and the coordinates of its center. This should be of type double. Use the new operator to create a Sphere object. Set and display its instance variables. 27 Write an application that defines a Circle class with two constructors. The first form accepts a double value that represents the radius of the circle. This constructor assumes that the circle is centered at the origin. The second form accepts the three double values. The first two arguments define the coordinates of the center and the third argument defines the radius. 28 Write an application that defines a sphere class with three constructors. The first form accepts no arguments. It assumes the sphere is centered at the origin and has a radius of one unit. The second form accepts one double value that represents the radius of the sphere. It assumes the sphere is centered at the origin .The third form accept four double arguments. These specify the coordinates of the center and the radius. 29 Write an application that demonstrates a class inheritance hierarchy. Class M extends Object and has two instance variable of type float and String. Class N extends M and has one instance variable of type Double. Instance class N initialize and display its variables. 30 Write a program that illustrates method overriding. Class Bond is extended by ConvertibleBond. Each of there classes defines a display() method that outputs the string “Bond” of “ConvertibleBond”, respectively. Declare an array to hold six Bond objects. Initialize the elements of the array with a mix of Bond and ConvertibleBond objects. Execute a program loop to invoke the display method of each object. 31 Write an application that illustrates how a method can invoke a superclass method. Class I2 is extended by J2.Class J2 is extended by K2.Each of these classes defines a getDescription() method that returns a string. That string includes a description of the class plus descriptions of each superclass. Instantiate each of these classes and invoke the getDescription() method. 32 Write a program that illustrates interface inheritance. Interface p is extended by P1 and P2.Interface p12 inherits from both P1 and P2.Each interface declares one constant and one method. Class Q implements P12.Instatiate Q and invoke each of its methods. Each method Displays one of the constants. 33 Assume that you created three packages named a.b.c.d, j.k.l.m, and r.s.t. the .class files for these packages are stored in directories c:lab8abc, c:freshmanchem101j klm,and c:semeinarrst,respectively.How should CLASSPATH be set so the classes and interfaces in those three packages can be located by JDK tools. 34 Write a program that illustrates how to use the throw statement. Create a class that
  • 3. has static method 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.Therefor,and ArryIndexOutOfBound Exception 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. 35 A method named average() has one argument that is an array of strings. It converts these to double values and returns their average. The method generates a NullPointerException if a array elements is null or NumberFormatException if an element is incorrectly formatted. Write a program that illustrates how to declare and use this method. Include throws clause in the method declaration to indicate that these problems can occur. 36 Write an application that reads a file and counts the number of occurrences of each digit between 0 and 9 .supply the file name as a command-line argument. 37 Write an application that reads and processes strings from the console. Reverse the sequence of characters in each string and then display it. 38 Write one application that writes the first 15 numbers of the Fibonacci series to a file. Use writeSort() method of DataOutputStrem to output the numbers. Write a second application that reads this data from a file and displays it. Use the readShort() method of DataInputStream to input the numbers. For both applications ,specify the name of the file a command-line argument. 39 Write an Applet which display one string named LDCE at the centre in red color. 40 Write an applet that draws a circle. The dimensions of the applet should be 500*300 pixels. The circle should be centered in the applet and have radius of 100 pixels.(Use the drawOval() method of Graphics.) 41 Write an applet that draws a rectangle and display one string in the center of the rectangle with yellow color. Also fill rectangle with blue color. The dimension of applet should be 500*300 pixels. 42 Write an applet which insets an image. 43 Write an applet that tracks the position of the mouse when it is dragged or moved. Draw a 10 * 10 pixel rectangle filled with black at the current mouse position. 44 Write an applet that contains one button. Initialize 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. 45 Write an applet and frame program that tracks the position of the mouse when it is dragged or moved. Print “hello” at the current mouse position. 46 Write an applet that contains three check boxes and 30 * 30 pixel canvas. The three check boxes should be labeled “red” ,”Green” and “Blue” .The selections of the check boxes determine the color of the canvas. for example ,if the user selects both “Red” and “Blue” the canvas should be purple.(Hint: Use the setBackground() and repaint() ,methods to change the color of the canvas) 47 Write a java frame program when mouse pressed in frame area ,each time new button added to frame. Write same program with different layout and see output. 48 Write a java frame program when mouse pressed in frame area new window is opened.When close button is pressed only one window should be closed. 49 Write a java frame program which shows use of button, menu bar and menu item. 50 Write an applet that contains one choice element and a 30 * 30 pixel canvas. The items in the choice element should be “red”, ”Green” and “Blue”. The Choice
  • 4. selection should determine the color of the canvas. 51 Write a program to display a random integer between 5 and 10 every three seconds. 52 Write a multithreaded program that simulates a set of grasshoppers jumping around in a box. Each grasshopper jumps to a different location every 2 to 12 seconds. Display the new location of a grasshopper after each of these jumps. 53 Write a multi thread java program to find factorial of a large number.