Practical java

N
nirmitnirmit
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.

Recomendados

Cse cpl manual-2016 von
Cse cpl manual-2016Cse cpl manual-2016
Cse cpl manual-2016Rajendra khatana
376 views124 Folien
I PUC CS Lab_programs von
I PUC CS Lab_programsI PUC CS Lab_programs
I PUC CS Lab_programsProf. Dr. K. Adisesha
6.4K views18 Folien
Mmt 001 von
Mmt 001Mmt 001
Mmt 001sujatam8
507 views6 Folien
Ecet 370 week 1 lab von
Ecet 370 week 1 labEcet 370 week 1 lab
Ecet 370 week 1 labagevpaswind1984
1.3K views4 Folien
Paper von
PaperPaper
Papermrecedu
201 views3 Folien
Intake 38 6 von
Intake 38 6Intake 38 6
Intake 38 6Mahmoud Ouf
173 views25 Folien

Más contenido relacionado

Was ist angesagt?

CP Handout#7 von
CP Handout#7CP Handout#7
CP Handout#7trupti1976
321 views6 Folien
Sp 1418794917 von
Sp 1418794917Sp 1418794917
Sp 1418794917lakshmi r
152 views11 Folien
Computer science sqp von
Computer science sqpComputer science sqp
Computer science sqpB Bhuvanesh
155 views15 Folien
C programming session 04 von
C programming session 04C programming session 04
C programming session 04Dushmanta Nath
1.4K views31 Folien
Intake 38 4 von
Intake 38 4Intake 38 4
Intake 38 4Mahmoud Ouf
197 views31 Folien
R Programming: Introduction to Vectors von
R Programming: Introduction to VectorsR Programming: Introduction to Vectors
R Programming: Introduction to VectorsRsquared Academy
1.8K views41 Folien

Was ist angesagt?(20)

Sp 1418794917 von lakshmi r
Sp 1418794917Sp 1418794917
Sp 1418794917
lakshmi r152 views
Computer science sqp von B Bhuvanesh
Computer science sqpComputer science sqp
Computer science sqp
B Bhuvanesh155 views
R Programming: Introduction to Vectors von Rsquared Academy
R Programming: Introduction to VectorsR Programming: Introduction to Vectors
R Programming: Introduction to Vectors
Rsquared Academy1.8K views
Java conceptual learning material von ArthyR3
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
ArthyR3284 views
Numerical analysis using Scilab: Numerical stability and conditioning von Scilab
Numerical analysis using Scilab: Numerical stability and conditioningNumerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioning
Scilab4K views
Numerical analysis using Scilab: Error analysis and propagation von Scilab
Numerical analysis using Scilab: Error analysis and propagationNumerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagation
Scilab4.9K views
Numerical analysis using Scilab: Solving nonlinear equations von Scilab
Numerical analysis using Scilab: Solving nonlinear equationsNumerical analysis using Scilab: Solving nonlinear equations
Numerical analysis using Scilab: Solving nonlinear equations
Scilab9.5K views

Destacado

List of programs for practical file von
List of programs for practical fileList of programs for practical file
List of programs for practical fileswatisinghal
8.3K views5 Folien
Bca sem 6 php practicals 1to12 von
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Hitesh Patel
12.6K views40 Folien
Advanced Java - Praticals von
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - PraticalsFahad Shaikh
1.6K views37 Folien
Advanced java practical semester 6_computer science von
Advanced java practical semester 6_computer scienceAdvanced java practical semester 6_computer science
Advanced java practical semester 6_computer scienceNiraj Bharambe
3.6K views41 Folien
tybsc it asp.net full unit 1,2,3,4,5,6 notes von
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
49.7K views153 Folien
Ad java prac sol set von
Ad java prac sol setAd java prac sol set
Ad java prac sol setIram Ramrajkar
31.9K views32 Folien

Destacado(7)

List of programs for practical file von swatisinghal
List of programs for practical fileList of programs for practical file
List of programs for practical file
swatisinghal8.3K views
Bca sem 6 php practicals 1to12 von Hitesh Patel
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12
Hitesh Patel12.6K views
Advanced Java - Praticals von Fahad Shaikh
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - Praticals
Fahad Shaikh1.6K views
Advanced java practical semester 6_computer science von Niraj Bharambe
Advanced java practical semester 6_computer scienceAdvanced java practical semester 6_computer science
Advanced java practical semester 6_computer science
Niraj Bharambe3.6K views
tybsc it asp.net full unit 1,2,3,4,5,6 notes von WE-IT TUTORIALS
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
WE-IT TUTORIALS49.7K views
Advanced Java Practical File von Soumya Behera
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
Soumya Behera14.3K views

Similar a Practical java

C# programming (3rd semester) von
C# programming (3rd semester)C# programming (3rd semester)
C# programming (3rd semester)Ketan Rajpal
218 views70 Folien
Programming qns von
Programming qnsProgramming qns
Programming qnsDr.Subha Krishna
75 views4 Folien
Lab exam question_paper von
Lab exam question_paperLab exam question_paper
Lab exam question_paperKuntal Bhowmick
56 views6 Folien
Assignment in java von
Assignment in javaAssignment in java
Assignment in javaMariel Canonicato
990 views2 Folien
C_Lab Manual_Part A.docx von
C_Lab Manual_Part A.docxC_Lab Manual_Part A.docx
C_Lab Manual_Part A.docxPandiya Rajan
6 views15 Folien
Assignment 3_2023.pdf von
Assignment 3_2023.pdfAssignment 3_2023.pdf
Assignment 3_2023.pdfamritapriyadarshinis
2 views3 Folien

Similar a Practical java(20)

C# programming (3rd semester) von Ketan Rajpal
C# programming (3rd semester)C# programming (3rd semester)
C# programming (3rd semester)
Ketan Rajpal218 views
C programming session 05 von Vivek Singh
C programming session 05C programming session 05
C programming session 05
Vivek Singh397 views
Data Structure.pdf von MemeMiner
Data Structure.pdfData Structure.pdf
Data Structure.pdf
MemeMiner12 views
IT-B PPS LAB SYLLABUS.pdf von kundurti
IT-B PPS LAB SYLLABUS.pdfIT-B PPS LAB SYLLABUS.pdf
IT-B PPS LAB SYLLABUS.pdf
kundurti3 views
HSc Computer Science Practical Slip for Class 12 von Aditi Bhushan
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12
Aditi Bhushan2K views
C programming exercises and solutions von Rumman Ansari
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
Rumman Ansari468 views
A01 von lksoo
A01A01
A01
lksoo368 views
You must submit your own work- For your solutions- only use the concep (1).pdf von solankeanna9
You must submit your own work- For your solutions- only use the concep (1).pdfYou must submit your own work- For your solutions- only use the concep (1).pdf
You must submit your own work- For your solutions- only use the concep (1).pdf
solankeanna92 views
This should be solved in the matrix.cpp file. Write a program which .docx von Komlin1
 This should be solved in the matrix.cpp file.  Write a program which .docx This should be solved in the matrix.cpp file.  Write a program which .docx
This should be solved in the matrix.cpp file. Write a program which .docx
Komlin12 views

Último

Monthly Information Session for MV Asterix (November) von
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)Esquimalt MFRC
72 views26 Folien
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx von
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxPharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxMs. Pooja Bhandare
113 views51 Folien
Psychology KS5 von
Psychology KS5Psychology KS5
Psychology KS5WestHatch
119 views5 Folien
Ch. 7 Political Participation and Elections.pptx von
Ch. 7 Political Participation and Elections.pptxCh. 7 Political Participation and Elections.pptx
Ch. 7 Political Participation and Elections.pptxRommel Regala
111 views11 Folien
CUNY IT Picciano.pptx von
CUNY IT Picciano.pptxCUNY IT Picciano.pptx
CUNY IT Picciano.pptxapicciano
54 views17 Folien
Jibachha publishing Textbook.docx von
Jibachha publishing Textbook.docxJibachha publishing Textbook.docx
Jibachha publishing Textbook.docxDrJibachhaSahVetphys
51 views14 Folien

Último(20)

Monthly Information Session for MV Asterix (November) von Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC72 views
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx von Ms. Pooja Bhandare
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxPharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Ms. Pooja Bhandare113 views
Psychology KS5 von WestHatch
Psychology KS5Psychology KS5
Psychology KS5
WestHatch119 views
Ch. 7 Political Participation and Elections.pptx von Rommel Regala
Ch. 7 Political Participation and Elections.pptxCh. 7 Political Participation and Elections.pptx
Ch. 7 Political Participation and Elections.pptx
Rommel Regala111 views
CUNY IT Picciano.pptx von apicciano
CUNY IT Picciano.pptxCUNY IT Picciano.pptx
CUNY IT Picciano.pptx
apicciano54 views
How to empty an One2many field in Odoo von Celine George
How to empty an One2many field in OdooHow to empty an One2many field in Odoo
How to empty an One2many field in Odoo
Celine George87 views
Use of Probiotics in Aquaculture.pptx von AKSHAY MANDAL
Use of Probiotics in Aquaculture.pptxUse of Probiotics in Aquaculture.pptx
Use of Probiotics in Aquaculture.pptx
AKSHAY MANDAL119 views
Psychology KS4 von WestHatch
Psychology KS4Psychology KS4
Psychology KS4
WestHatch98 views
Solar System and Galaxies.pptx von DrHafizKosar
Solar System and Galaxies.pptxSolar System and Galaxies.pptx
Solar System and Galaxies.pptx
DrHafizKosar106 views
Structure and Functions of Cell.pdf von Nithya Murugan
Structure and Functions of Cell.pdfStructure and Functions of Cell.pdf
Structure and Functions of Cell.pdf
Nithya Murugan719 views
The basics - information, data, technology and systems.pdf von JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1146 views
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB... von Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
Relationship of psychology with other subjects. von palswagata2003
Relationship of psychology with other subjects.Relationship of psychology with other subjects.
Relationship of psychology with other subjects.
palswagata200352 views
Create a Structure in VBNet.pptx von Breach_P
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptx
Breach_P78 views
Ch. 8 Political Party and Party System.pptx von Rommel Regala
Ch. 8 Political Party and Party System.pptxCh. 8 Political Party and Party System.pptx
Ch. 8 Political Party and Party System.pptx
Rommel Regala54 views

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.