java manual.docx

Upload: 9897856218

Post on 03-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 java manual.docx

    1/2

    JAVA PROGRAM LIST

    Week 1&2(ques1-10) week 3&4(ques11-20)

    Instruction: Highlighted question are for Practical File.

    1. a) Write a java program to print hello world.b) Write a java program to input value of a variable a and display the input value.

    c) Write a java program to calculate largest of 3 nos. input (Using scanner class).

    2. Write a java program to check whether input number is Armstrong number.3. Write a java program to check whether input number is palindrome or not.4. Write a program to input three side of triangle than calculate area of triangle.5. Write a program to simulate Calculator using switch case.6. Write a java program to practice String class and its method.7. a) Write a java program to search a key in an array of 10 elements.

    b) Write a java program to perform addition of two matrices.

    8. Write a java program to find largest of three numbers using conditional operator.9. a) Write a java program for the following: Define a class called MyRectangle with instance

    variables called length and width and methods setData() and rectArea(). SetData() method

    inputs two argument values from user for setting length and width of the rectangle. rectArea()

    calculates area of rectangle and returns it.

    b) Write a java program for the following: declare a class called MyDate which contains dd,

    mm and yy as instance variables and getDay (), getMonth (), getYear () and setDate () as public

    methods that allow access to private variables. Also write a test class that declares an object of

    class MyDate and instantiates it. Call upon the method setdate () to set values of instance

    variables. The call

    getDay (), getMonth () and getYear () and print their values.

    10.Write a program that displays the order details of fruits. Define a constructor with parameters forproduct name, quantity and price.

    11.Write a java program to accept a string from user and find out the following:no. of lowercase characters,

    no. of uppercase characters,

    no. of digits,

    no. of words,

    total no. of characters,

    no. of symbols12.Write a java program to covert temperature in Celsius to temperature in Fahrenheit and vice versa.

    Use inheritance to define a base class containing abstract method named convert (). Define twoderived classes to override the convert () method. One derived class will convert Fahrenheit toCelsius and other will perform vice versa.

    13.Write a java program to create a super class called employee and two subclass named managerand clerk. The employee class contains following attributes name, code, dept, address, email_id,

    mobile _no and a method called show () which displays values of attributes. The manager class

    has an additional attribute known as transport allowance.

    14.Write a java program to override an abstract method named add () of base class addition. add () willadd two nos. in NumberAddition class and concatenate the strings in TextConcatenate class. Declareand initialize attributes in constructor of base class addition.

  • 7/28/2019 java manual.docx

    2/2

    15.Write a java program to create an interface that consists of a method to display grades ofstudents. Create a class that implements the interface and displays grades according to

    percentage of marks obtained.

    16.Write a java program to accept and print the employee details during runtime. The details will includeemployee id, name, designation, dept_ Id. The program should raise an exception if user inputsincomplete or incorrect data. The entered value should meet the following conditions:

    (i) Employee name should be string.(ii) Employee id should be integer.(iii) Department id should be an integer between 1 and 5.If the above conditions are not met then the application should raise an exception and executestatements from appropriate catch classes.

    17.Write a java program to create a package MyMath and define a class MathOperation under it. Theclass defines 3 methods namely add (), sub (), multiply (), div () to perform addition, subtraction,multiplication and division, respectively. Create another class which imports this package and uses

    these methods for computing values.

    18.Write a java program to copy file1.txt into file2.txt. The names of source and destinationfiles are input from user.