Thursday 17 November 2011

ANNAUNIVERSITY QUESTION PAPER:

B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2010

IT 2301 — JAVA PROGRAMMING
PART A — (10 × 2 = 20 Marks)
1. What is the difference between static and non-static variables?
2. What is the purpose of finalization?
3. What is the difference between the String and String Buffer classes?
4. Can an abstract class be final? Why?
5. What is an anonymous inner class?
6. What is the difference between the File and Random Access File classes?
7. What are the advantages of the event-delegation model?
8. What happens if an exception is not caught?
9. What is the use of Reflection API?
10. What are three ways in which a thread can enter the waiting state?

PART B — (5 × 16 = 80 Marks)

11. (a) Explain briefly the following object oriented concepts.
(i) Abstraction and Encapsulation. (4)
(ii) Methods and messages. (4)
(iii) Inheritance. (4)
(iv) Polymorphism. (4)
Or

(b) (i) How objects are constructed? Explain constructor overloading with
an example. (Marks 10)
(ii) Write short notes on access specifiers in java. (Marks 6)

12. (a) What is a Package? What are the benefits of using packages? Write down
the steps in creating a package and using it in a java program with an
example. (Marks 16)
Or
(b) What is Dynamic binding? Show with an example how dynamic binding
works. (Marks 16)

13. (a) What is object cloning? Why it is needed? Explain how objects are cloned.
(Marks 16)
Or
(b) How is a Frame created? Write a java program that creates a product
enquirer form using frames. (Marks 16)

14. (a) With a neat diagram explain the Model view controller design pattern
and list out the advantages and disadvantages of using it in designing an
application. (Marks 16)
Or
(b) What is an Exception? Explain how to throw, catch and handle
Exceptions. (Marks 16)

15. (a) What is Generic programming and why is it needed? List the limitations
and restrictions of generic programming. (Marks 16)
Or
(b) Explain how to create threads. Write a java program that prints numbers
from 1 to 10 line by line after every 5 seconds. (Marks 16)





  
B.E./B.Tech. DEGREE EXAMINATION, APRIL/MAY 2011
Fifth Semester Information Technology
IT 2301 — JAVA PROGRAMMING
PART A — (10 × 2 = 20 marks)
1.  Give the properties of abstract classes and methods and write a suitable
example.
2.  Why does Java not support destructors and how does the finalize method
help in garbage collection?
3.  Write a declaration to convert the value ‘‘Programmer’’ in the string
variable ‘convert’ to ‘‘programming’’.
4.  Distinguish between static and dynamic binding.
5.  How does the declaration of a local inner class differ from the declaration
of an anonymous inner class?
6.  Write a code to copy the contents of the file input.txt one byte at a time to
output.txt using FileInputstream and FileOutputStream.
7.  When do the following events occur?
  (a) AdjustmentEvent
  (b) ItemEvent
8.  Write down the statements used to create a JFrame and a JButton and
then add the JButton to the JFrame.
9.  List any two advantages of type parameters.
10.  When would you use the CountDownLatch synchronizers and Exchange
Synchronizers?
PART B — (5 × 16 = 80 marks)
11.  (a) (i) Write a program to find whether a number is a palindrome or
not.   (8)
   (ii) Discuss the working and meaning of the ‘‘static’’ modifier with
suitable examples.   (8)
Or
  (b) Explain in detail as to how inheritance and polymorphism are
supported in Java with necessary examples. (16)
12.  (a) (i) Write a Java program to perform matrix multiplication using
arrays.   (8)
   (ii) Write a java program to search for a number in the given array
using binary search.   (8)
Or
  (b) Give a detailed explanation of packages in Java(16).
13.  (a) What is reflection and how does it help to manipulate java code?  (16)
Or
  (b) Consider a class person with attributes firstname and lastname.
Write a java program to create and clone instances  of the Person
class. (16)
14.  (a) Write a program to create a calculator using swings with the four
basic arithmetic operations : +, –, *, /. (16)
Or
  (b) Draw the exception hierarchy in java and explain with examples
throwing and catching exceptions and the common exceptions.(16)
15.  (a) With suitable examples consider the number of restrictions to
consider when working with java generics. (16)
Or
  (b) Write short notes on what threads are and the thread states and
properties. (16)






Friday 14 October 2011

IT2305 JAVA PROGRAMMINg QUESTION BANK:

IT2301 QUESTION BANK:
PART-A:
1.       What is the difference between static and non-static variables?\
2.       What is the purpose of finalization?
3.       What is the difference between the String and String Buffer classes?
4.       Can an abstract class be final? Why?
5.       What is an anonymous inner class and static inner class?
6.       What is the difference between the File and Random Access File classes?
7.       What are the advantages of the event-delegation model?
8.       What happens if an exception is not caught?
9.       What is the use of Reflection API?
10.   What are three ways in which a thread can enter the waiting state?
11.   Give thae properties of abstract class and methods.
12.   Why does java not support destructors and how does the finalize method will help in garbage collections?
13.   Write a declaration to convert the value of “Programmer” in the string variable ‘convert’ to Programming”.
14.   Distinguish between dynamic and static binding. What are the advantages of the event-delegation model?
15.   Define Proxy class and its methods.
16.   State the properties of interface.
17.   Write down the statements used to create a JFrame and a JButton and then add the JButton to the JFrame.
18.   List any two advantages of type parameters.
19.   When would you use the CountDownLatch synchronizers and Exchange Synchronizers?
20.   When do the following events occur?
i)AdjustmentEvent   ii)ItemEvent
PART-B:
Unit-I:
  1. How objects are constructed? Explain constructor overloading with
    an example.
  2. Write short notes on access specifiers and modifiers in java.                 
  3. Write a java program to check whether the number is palindrome or not.
  4. State the design hints for class and inheritance and also discuss the working  
    and meaning of the “static” modifier with suitable examples.                  
  5. Explain in detail as how inheritance and polymorphism are supported in java     
     with necessary example.          
  6. Explain the concept of finalizaion.Explain the finalize() method with an   
    example program and explain about mutators.
  7. Discuss the working and meaning of the “static” modifier with example.and   explain static variable and static methods with an example program.
  8. Explain about  Encapsulation,Abstraction.
  9. Define constructor. How objects are constructed? Explain constructor    overloading with an example.
  10. write a java program to check whether the number is prime or not.
UNIT-II:
  1. What is a Package? What are the benefits of using packages? Write down
    the steps in creating a package and using it in a java program with an example.
  2. Write a java program to search for a number in the given array using binary    search method.
  3. Explain about Java Documenation comments with an example programs.
  4. What is Dynamic binding? Show with an example how dynamic binding
     works.
  5. Explain about arryas,Type of arrays and arrays methods.
  6. Explain about Final class,Fields,Methods.
  7. Explain about different types of string methods.
  8. Write a java program to implement the multiple inheritance concept for calculating area of circle and square.
  9. Design a Java package for numbers. Develop two different classes that belongs to two package, one for to check whether the given number is palindrome or not and the other to check whether the given number is odd or even and access these package using one main file
  10. Design a Java interface for numbers. Develop two different classes that implement this interface, one for to check whether the given number is palindrome or not  and the other to check whether the given number is odd or even.
  11. Develop a java code to implement the interface concept for finding the sum and average of given N numbers

UNIT-III:
  1. Explain the concept of inner classes and explain the types of inner classes   
    with an example program.        
  2. What is reflection and how does it help to manipulate java code.
  3. How is a Frame created? Write a java program that creates a Online Education Loan System.
  4. Consider a class person with attributes firstname and lastname.Write a java program    
    to create and clone instances of the Person class.
  5. Write short notes about I/O stream classes.
  6. How is a Frame created? Write a java program that creates a product enquirer form using frames.
  7. Explain about interface with an example programs.
  8. Explain about Graphics programming and  Expalin all 2D packages and classes.
  9. Write a java program to implement the reflection concept for Date class.
  10. Write a java program to draw the circle,ellipse,rectangle in the frame using Java swing.
  11. Develop a java swing program to display 8 swing buttons and arrange that components using grid format.
  12. Develop  a java swing code to create G-mail sign-in form with grid layout format.
  13. Expalin about Paoxy class,Interface and Methods.
  14. Develop a simple paint-like program that can draw basic graphical primitives in different dimensions using java swing.
  15. Explain about callback.
UNIT-IV:
  1. With a neat diagram explain the Model view controller design pattern
     and list out the advantages and disadvantages of using it in designing an
      application.
  2. write the short notes about swing components with menu example  
     programs.
  3. What is an Exception?Explain the exception hierarchy. Explain how to  
     throw, catch and handle Exceptions.
  4. Write the java swing program to create the g-mail sign in form and display  
     that content to text area using insert button.
  5. Explain about adapter classes and mouse events with an example.
  6. Explain themenu components.Write a swing program to display the “FILE”       
     menu(Menu Item:NEW,OPEN,SAVE,SAVE AS) with “SAVE AS” sub menu.
  7. Explain about Layout management and AWTEvent hierarchy.
UNIT-V:
  1. Explain the thread state,thread properties and thread synchronization.
  2. Write a java program that prints numbers   from 1 to 10 line by line after 
     every 5 seconds.
  3. Briefly explain about the Thread Synchronization and synchronized keyword   
    with an example program.
  4. With a neat diagram explain the thread states.
      5.    Explain the following term:                                                                   
     1.Generic reflection
      2.Inheritance rules for generics
      3.Bounded types & Unbounded types.
      4.Limitations and restrictions of Generic programming.    
       6.  What is Generic programming and why is it needed?Explain with example. List 
             the limitations and restrictions of generic programming
       7.                              


Tuesday 11 October 2011

Some Example programs

Inheritance Area:
import java.util.*;
class rectangle
{
int l,h,rect;
Scanner sc=new Scanner(System.in);
void get()
{
System.out.println("Enter The Length Of The Rectangle");
l=sc.nextInt();
System.out.println("Enter The Height of the Rectangle");
h=sc.nextInt();
rect=l*h;
}
void put()
{
System.out.println("Area Of Rectangle="+rect);
}
}
class square extends rectangle
{
int a,area;
void gett()
{
System.out.println("Enter The Value For The Square");
a=sc.nextInt();
area=a*a;
get();
}
void putt()
{
System.out.println("Area Of Square="+a);
put();
}
public static void main(String args[])
{
square sq=new square();
sq.gett();
sq.putt();
}
}


PROGRAM:
GRID LAYOUT:

import javax.swing.*;
import java.awt.*;

class sss
{
public static void main(String args[])
{

JFrame f=new JFrame();

JPanel p=new JPanel();
f.setTitle("Calculator");
f.setSize(300,300);

JButton b1=new JButton("ADD");
JButton b2=new JButton("sub");
JButton b4=new JButton("DIV");
JButton b5=new JButton("MUL");
JButton b6=new JButton("LOG");
JButton b7=new JButton("SQUARE");
JButton b8=new JButton("ROOT");
JButton b9=new JButton("1/X");
p.add(b1);
p.add(b2);

p.add(b4);
p.add(b5);
p.add(b6);
p.add(b7);
p.add(b8);
p.add(b9);
f.add(p);
GridLayout g=new GridLayout(2,2);
p.setLayout(g);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);


}
}





SIGN IN FORM:

import javax.swing.*;
import java.awt.*;

class sss
{
public static void main(String args[])
{

JFrame f=new JFrame();

JPanel p=new JPanel();
f.setTitle("Calculator");
f.setSize(300,300);
JLabel jj=new JLabel("USER NAME");
JLabel jj1=new JLabel("PASSWORD");
JTextField th=new JTextField("");
JPasswordField ps=new JPasswordField("");
JButton b1=new JButton("SUBMIT");
p.add(jj);
p.add(th);
p.add(jj1);
p.add(ps);
p.add(b1,BorderLayout.SOUTH);
f.add(p);
GridLayout g=new GridLayout(1,1);
p.setLayout(g);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);


}
}
FACTORIAL USING PACKAGE:
package p1;
import java.util.*;
public class sss{

public void fact()
{
Scanner sc=new Scanner(System.in);
  System.out.println("enter the number");
  int a=sc.nextInt();
  int fact= 1;
  System.out.println("Factorial of " +a+ ":");
  for (int i= 1; i<=a; i++){
  fact=fact*i;
  }
  System.out.println(fact);
  }
 
Main File:
Import p1.*;
Class main
{
Public static void main(String args[])
{
 Sss s=new sss();
s.fact();
}
}


Factorial using interface:
import java.util.*;
interface if
{
public void fact();
}
class sss implements if
{
int a;
Scanner sc=new Scanner(System.in);
 
public void fact()
{

  System.out.println("enter the number");
 a=sc.nextInt();
  int fact= 1;
  System.out.println("Factorial of " +a+ ":");
  for (int i= 1; i<=a; i++){
  fact=fact*i;
  }
  System.out.println(fact);
  }
public static void main(String args[])
{
sss s=new sss();
s.fact();
}
}