0% found this document useful (0 votes)
2 views

java assignment

The document contains a series of assignments from Disha Computer Institute focused on various Java programming topics, including Core Java, command line arguments, inheritance, interfaces, multithreading, and applet graphics. Each assignment includes multiple programming tasks that require students to implement specific functionalities, such as calculating areas, using classes and methods, handling exceptions, and creating graphical outputs. The assignments are structured to progressively build students' understanding and skills in Java programming.

Uploaded by

mlneha9254
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

java assignment

The document contains a series of assignments from Disha Computer Institute focused on various Java programming topics, including Core Java, command line arguments, inheritance, interfaces, multithreading, and applet graphics. Each assignment includes multiple programming tasks that require students to implement specific functionalities, such as calculating areas, using classes and methods, handling exceptions, and creating graphical outputs. The assignments are structured to progressively build students' understanding and skills in Java programming.

Uploaded by

mlneha9254
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Disha Computer Institute vita.

Core Java Assignment

Assignment-1

Topic Covered: Basic of Java, Control Structure, Arrays

1. Write a java program to display a welcome message.


2. WAP to find the square of two numbers if value of number is constant.
3. WAP to find the simple interest if value of P, N, R is assigned a constant value.
4. WAP to find out the greater number between 3 values.
5. WAP to print the following format.
a) * b) **** c) *
** *** **
*** ** ***
**** * ****
****
d) e) *
***
* *
**
* * *
*
6. WAP to find out the factorial of number if number is constant
7. WAP to prints the following triangle of binary digit.
101
10001
1000001
10000001
8. WAP to find out the sum of series of 1D array if value of array is constant.
9. WAP to find out addition of two 1D array.

10. WAP to find out addition of 2D array if value is constant.

11. WAP to find the sum of the series of 1+x+x2+x3.........

12. WAP to print the square of 1 to 10 no.


Disha Computer Institute vita.

Assignment-2

Topic Covered: Command Line Argument, More Than One Class,


Method Overloading

1. WAP to find the number is even or odd if number is pass by command line argu-
ment.
2. WAP to area of circle if radius is given in command line argument.
3. WAP to make a class for find out the area of rectangle using of another class hav-
ing class name is rect.
4. WAP to make class student that have two method setdata() and showdata().The
setdata methods assign the detail of student which is passed through main
method and showdata display the detail of student.
5. WAP to define a part class with attributes length, breadth and area. Define a suit-
able constructor and a method to display the object.
6. WAP to swapping of two numbers using method overloading.
7. WAP to square of number float and int (hint: using of method overloading).
8. WAP to for test passed number is int ,double or char using method overloading
Disha Computer Institute vita.

Assignment-3

Topic Covered: Inheritance, Method overriding, Super keyword, Fi-


nal, Abstract class.

1. WAP to make one class A which have one method as msg() for display the wel-
come message. Create one more class B which derived from the class A and in
derived also have one show () method which display the message “Derived
class”.
2. Create a base class initializing 2 variable a & b in its constructor. There is an-
other class der which inherit base class .The class der has method multiply ()
which will multiply the 2 numbers from base class and display the result in main
(). (Use super keyword to invoke the constructor of base class).
3. WAP make one base class having one variable and create one derived class
which extend from the base class. In derived class have a one variable there
name is same as base class variable name& one show () method which will dis-
play the value of base class variable & derived class variable. (Hint: using super
keyword).
4. WAP to make one base class having one method as msg () for display the wel-
come message & one derived class having same method msg () which are dis-
play message” this is derived class method”. (Using method overriding).
5. Use the program 4 makes the some changes in that program. Write the final
keyword before the show () method in base class and check the result of that.
(That demonstrates the use of final keyword).
6. WAP to make one class A having two variable as height, width &two method
set() which are initialize the value of height & width passed from the main
method and one abstract method as area() which find out the area of rectan-
gle.(use abstract method)
Disha Computer Institute vita.

Assignment-4

Topic Covered: Interface And Packages.

1 .WAP to make a one interface having two method as empinfo () and emp-
show().Create new class which is derived from the interface. The empinfo record
the details of employee like employee id, salary and empshow() display the detail
of employee.

2. WAP to make an interface having one method as calc() which calculate the area
of circle. Create a new class derived from the interface and show the result.

3. WAP to make a one package as PACK this package having one method for display
the welcome message. Make another program and import that package on it and
call that method.

4. WAP to make a one package in this package having three method as sum(),
fact(), sqr() which calculate the sum of two number, factorial of number and square
of number respectively. Test this package is another program using import and
called method.

5. WAP to make a one package having one method prime(). Make another program
and import that package and called method with send number. Check that number
is prime or not.

6 .WAP to make a one package having one method arraysum().Import that package
in another program find sum of one dimensional array when array value is pass by
parameter. Array value is accepted through command line argument.
Disha Computer Institute vita.

Assignment- 5

Topic Covered: Multithreading, exception handling, java I/O, String


handling.

1. WAP having three threads calculate the square of number, second thread calcu-
late factorial of number and third thread display the multiplication table of num-
ber 2.

2. WAP to divide the two numbers in try-catch block if number is division by zero
then display the error message “DIVIDE BY ZERO”.

3. WAP to insert the value in array and display it, if inserting value is overflow then
display the error.

4. WAP to accept the name and roll no and display it.

5. WAP to accept the two numbers and generate the Fibonacci series.

6. WAP to accept the two string and compare both string are same or not.

7. WAP to accept the string “assignment” and display there length, Find the occur-
rence of ‘s’ letter in given string.

8. WAP to accept the two string and displayed concatenated string.

9. WAP to accept the string “multithreading” and replace the ‘t’ letter to ‘k’ letter.

10. WAP to accept the string “cat cation” and insert the “edu” in position 5.

11. WAP to accept the string “cat education sim technologies” extract the letter ‘e’
in first occurrence of that letter and also extract the ‘sim’ in given string.
Disha Computer Institute vita.

Assignment- 6

Topic Covered: Applet, Graphic.

1. WAP to display the “WELCOME TO APPLET PROGRAM” using applet.

2. WAP to print square of number using applet.

3. WAP to change the background & text color to yellow & red respectively using
applet.

4. WAP to make the one rectangle , circle, rounded rectangle.

5. WAP to make one filled with red color of rectangle, yellow filled oval, blue fill
rounded rectangle.

6. WAP to display the message in applet & set the font as comic sans MS, size as
30, style as bold, text color red.

7. Make following graphics.

8. Make following using graphics filled rectangle with given color in rectangle.

Yellow color

Green color

Red color
Disha Computer Institute vita.

9. Make following using graphics.

10. Make following using graphics.

11. Make following using graphics.

12. WAP to create a window & draw horizontal and vertical line to form grid like

You might also like