You are on page 1of 2

JAVA PROGRAM LIST Week 1&2(ques1-10) 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 for product 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 symbols 12. 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 two derived classes to override the convert () method. One derived class will convert Fahrenheit to Celsius and other will perform vice versa. 13. Write a java program to create a super class called employee and two subclass named manager and 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 () will add two nos. in NumberAddition class and concatenate the strings in TextConcatenate class. Declare and initialize attributes in constructor of base class addition. week 3&4(ques11-20)

15. Write a java program to create an interface that consists of a method to display grades of students. 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 include employee id, name, designation, dept_ Id. The program should raise an exception if user inputs incomplete 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 execute statements from appropriate catch classes. 17. Write a java program to create a package MyMath and define a class MathOperation under it. The class 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 destination files are input from user.

You might also like