-
Pass student name using command line argument and print output in following format: First Name : abc Second Name : pqr Last Name : str
-
Write a program to check whether given number is even or odd.
-
Write a program that displays the value of 2 raised to the power 12.
-
Write a program check primality of a number.
-
Write a program to print following triangle with character ‘A’ for n rows, n is to be passed as command line argument. A A A A A A A A A A
-
Write an application that accepts two doubles as its command-line arguments, multiplies these together, and display the product.
-
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.)
-
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
-
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.)
-
Write an application that generates the first 15 numbers in the Fibonacci series.
ARRAY
-
Write an application that creates an array with five Float command line arguments and display the length of the array after creation and its elements.
-
Write a program that creates and initializes a four element byte array. Calculate and display the average of its values.
-
Write a program to search in the int array with use of for each style for loop.
-
Create two dimensional array of int with user given input. Display the summation of all elements of 2D array using for each loop.
STRING HANDLING
-
Write a program that will create two strings using new keyword, compare them and show true if they are same, append second to first.
-
Write a program that will accept a string “java123is234fun” will replace all occurrences of digit with single space character in a new string. (use of replaceAll() function and regular expression for digit). Split the new formed string from space character and form the array of strings (use of split function). Display strings from the array in new line each.
-
Write a program that displays the substring formed by the last ten characters of a string given as command line argument.(Use length() method)
-
A string contains five numbers separated by commas .Write a program that displays the last number.
-
Write an application that counts the total number of characters in all of its command-line arguments.
-
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.
-
A method named average() has one argument that is an array of strings. It converts these to double values and returns their average. Write a program that illustrates how to declare and use this method.
-
Write an application that reads and processes strings from the console(stays at console). Reverse the sequence of characters in each string and then display it.
-
Create a StringBuffer object and illustrate the operation of the append() and reverse() methods.
CLASS
-
Write a program to create circle class with area function to find area of circle.
-
Define class complex with a function to add and to compare to complex number.
-
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.
-
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 (will set center coordinates to zero). 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. Set and display its instance variables.
-
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.
-
Create circle class then derive cylinder class with overriding of area calculation method.
-
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.
-
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
Exception handling
-
Write a program that will accept two integers with the use of command line or scanner class. Divide first integer by second, display the result and also handle appropriate exception if second number is zero.
-
Write a program to accept age of user with the use of commandline or scanner class. Create and throw user defined exception named “InvalidAge” with error message.