Java Programming Laboratory

Lab manual

Sub Code: 15046

OPERATORS AND EXPRESSIONS

  1. a).Write a Program to find the area of a rectangle.
    b)Write a program to find the result of following expressions (Assume a = 10, b = 5)
    i) (a << 2) + (b >>2) ii) (a) || ( b>0) iii) ( a + b * 100) /10 iv) a & b
    c)Write a program to print the individual digits of a 3-digit number.

    DECISION MAKING STATEMENTS
  2. a).Write a program that asks the user to enter two integers, obtains the numbers from the user, and then prints the larger number followed by the words "is larger." If the numbers are equal, print the message “These numbers are equal.”
    b)Write a program that reads an integer and determines and prints whether it is odd or even.
    c)Write a program to find the biggest number between the given three integer numbers.

    LOOPING STATEMENTS
  3. a) Write a program to find the sum of the digits of a given number.
    b) Write a program to find the first 15 terms of the Fibonacci sequence.
    c) Write a program to find the three digit Armstrong numbers.

    ARRAYS
  4. a).Write a program to read N numbers and find the largest and smallest numbers.
    b) Write a program for the multiplication of two matrices.

    VECTORS
  5. Write a program that accepts a shopping list of four items from the command line and stores them in a vector. Write a Menu based Program to perform the following operations using vector
    1. To add an item at a specific location in the list.
    2. To delete an item in the list.
    3. To print the contents of the vector.
    4. To delete all elements
    5. To add an item at the end of the vector.

    STRINGS AND STRINGBUFFER
  6. a) Write a program in Java to create a String object. Initialize this object with your name. Find the length of your name using the appropriate String method. Find whether the character ‘a’ is in your name or not; if yes find the number of times ‘a’ appears in your name. Print locations of occurrences of ‘a’.
    b) i. Create a StringBuffer object and illustrate how to append characters. Display the capacity and length of the string buffer.
    ii. Create a StringBuffer object and illustrate how to insert characters at the beginning.
    iii. Create a StringBuffer object and illustrate the operations of the append() and reverse() methods.

    CLASSES AND OBJECTS
  7. a).Write a program to display total marks of 5 students using student class. Given the following attributes: Regno(int), Name(string), Marks in subjects(Integer Array), Total (int).
    b) Write a program in Java with class Rectangle with the data fields width, length, area and colour. The length, width and area are of double type and colour is of string type. The methods are get_length(), get_width(), get_colour() and find_area().
    Create two objects of Rectangle and compare their area and colour. If the area and colour both are the same for the objects then display “ Matching Rectangles”, otherwise display “ Non-matching Rectangle”.

    PASSING OBJECTS AS ARGUMENTS
  8. Create a class to represent complex numbers. A complex number has the form real part + i * imaginary part. Provide constructor to enable an object of this class to be initialized when it is declared. Provide a no-argument constructor with default value in case no initializes are provided. Provide public methods for the following:
    i) Addition of two complex numbers
    ii) Subtraction of two complex numbers
    iii) Printing complex numbers in the form (a,b) where a is the real part and b is the imaginary part.
    (Pass objects as arguments)

    INHERITANCE
  9. Write a program to create a player class. Inherit the classes Cricket_player, Football_player and Hockey_player form player class.

    INTERFACES
  10. a).Write a program to show how a class implements two interfaces.
    b) Show through a program that fields in an interface are implicitly static and final and methods are automatically public.

    PACKAGES
  11. Write a program to create a package for Book details giving Book Name, Author Name, Price, year of publishing.

    APPLETS AND AWT
  12. A color can be created by specifying the red, green, blue values as integer parameters to the constructor of class Color. The values range from 0 to 255. Provide three horizontal scroll bars and ask the user to select the values of the colors by dragging the thumb in the scroll bar. Using the color selected, draw a rectangle.
  13. Create an applet for simple calculator to perform Addition, Subtraction, Multiplication and Division using Button, label and Text field classes.
  14. Draw a bar chart for the following details using Applets.
Subject Tamil English Maths Physics
Marks 75 85 98 56

EXCEPTION HANDLING

  1. a)Write a Java program to catch more than two exceptions.
    b)Write a Java program to create your own exception subclass that throws exception if the sum of two integers is greater than 99.

    MULTITHREADING
  2. Write a Java program for generating two threads, one for printing even umbers and other for printing odd numbers.
  3. Write a Java program for producer and consumer problem using Thread.

    NETWORKING
  4. Write a program to transfer the file between client and server using TCP/IP FILES
  5. a)Write a program to create a text file using Byte stream classes
    b)Write a program to copy a file to another file.

    CONNECTING DATABASE
  6. Write a Java Program to connect to a database created in MS-ACCESS using JDBC Concept. Perform basic operations of Selection, Insertion and deletion on the database.

REQUIREMENTS:
Software:

  • JDK1.3 OR JDK1.4
  • MS -ACCESS

    Hardware:
  • Computer with Pentium IV / Dual core Processors. – 36 Nos
  • Printer – 3 Nos

From the Web

Suggestions: (2)
Loading...

See few results | more results

Search: [Press Enter]

Share |