Java Programming

Chapter 1:-Introduction to java
1)Write a short note on strings .Explain any 4 methods of the string class.
2)Differentiate String and String Buffer class.
3)Write a short note on data types in java.
4)Explain each term in public static void main(string args[]).
5)What are the different ways to create an object in java ?
6)What is JVM ?
7)What is instance variable?
8)Explain arrays in java. How does it differ from C++ ?
9)Java is platform independent .Justify the statement
10)Does the order of public static void matters in main()method. ?
11)How to print “welcome “message before main()method is executed ?

Chapter 2:-Classes  and Objects
1)List Access specifiers used in java
2)List Java non access modifiers.
3)Explain   in default access specifier
4)Explain  runtime polymorphism in java with example.
5)Differentiate between abstract class and interface.
6)Write similarities and dissimilarities between Abstract class and Interfaces.
7)What is the need of user defined package? Explain with example.
8)Explain Inheritance in java.
9)Define anonymous object.
10)What is abstract method ?
11)Explain method overriding in java with suitable example.
12)Write a short note on inner class.
13)How is multiple inheritances achieved in java? Explain with example
14)State the purpose of wrapper class
15)Can we use super() and this ()within the same constructor? Justify
16)What type of variables can be defined in an interface ?
17)Write the steps and rules used to create user defined package.
18)Explain the use of super and final keywords with reference to inheritance

Chapter 3:-Collection
1)Define Map in collection framework.
2)Write a short note on Collection Framework.
3)Define set interface in collection framework.
4)What is the use of iterator in collection framework.?
5)Explain Array list class in collection framework.
6)What is collection framework
7)List any two differences between Hash Map and Hash Table.
8)What is a vector
9)Define collection. Explain any two classes used with collection
10)Explain the need of Garbage collection in java

Chapter 4:-File and Exception Handling
1)What is finalize()method.
2)What is Exception?
3)List any 2 built-in Exceptions in java.
4)Explain Exception handling in java with an example.
5)Write down the difference between throw and throws clause in Exception handling.
6)Explain FileInputStream and FileOutputStream classes in java.
7)List keywords used in Exception handling.
8)Explain exception handling with example.
9)Explain try and catch with class
10)Give syntax of 2 methods used with input stream class.
11)Can a finally block be executed without catch block ? justify
12)Write a note on event handling.
13)Explain the following keyword final, finally, finalized
14)Explain any 4 methods of file class
15)What are the different types of byte streams in java
16)What is the use of file class

Chapter 5:-Applet ,AWT and Swing Programming.
1)List any two listeners used in event handling
2)Explain Event Delegation model in java
3)List Layout Managers used in .awt.
4)Explain Applet Life Cycle.
5)What is Adaptor class? Explain use of Adaptor classes in java with an example.
6)What is the use of ‘this’ keyword.?
7)Explain life cycle of Applet.
8)What is listener ? Explain any one Listener interface with its methods.
9)What is AWT ? How to add any component on frame using AWT ?
10)List types of Applet
11)Can you save a java source file by name than class name.
12)What is adapter class? Explain its purpose. List any 2 adaptor classes
13)What is event handling ? Explain with example.
14)State any four interfaces used in event handling
15)Can an Applet have a constructor? Justify
16)What is Layout Manager? Explain any one in detail.
17)State the difference between AWT and Swings
18)What is a listener ? Explain the mouse Listener methods
19)Which container uses border layout as its default layout?
20)List any two restrictions for applets.
21)What is Adaptor class ? Explain its purpose.
22)What are the different types of dialog available in java? Explain in any 2 in detail.

Solved the Program.
1)Write a java program to accept names of n cities from user and display them in ascending order.

2)Write a program to create an interface shape. Create two classes circle and rectangle implementing that interface .Display area of circle and area of rectangle.

3)Write a  java program to create a class Employee(eno,ename,age, salary).If age is less than 18 then raise an exception ‘Age not valid Exception ‘else display the record.

4)Write a java program to display “Hello java with Font-Arial, Foreground Color-Blue, Background-Red on the frame.

5)Write a program to accept the details of ‘n’ employees(ename,salary)from the user, store them into the Hash table and display the Employee name having maximum salary.

6)Write a program to create package TYBCA which has two classes subject and marks, Subject class is to accept subjects and marks class is to accept marks. Create main class which will use package and calculate total and percentage.

7)Write a java program using AWT to display current date and time and also wish the user accordingly.(if it is am, wish user “Good Morning”.)

8)WAP a java program to accept filename from commandline.Find its total size in bytes. Display error message if file does not exist.

9)Write a java program to read the characters from a file, if a character is alphabet then reverse its case, if not then display its category on the screen(whether it is digit or space).

10)Write a java program to accept ‘n’ no through the command line and store all the prime no’s into an array and display.

11)WAP to read n students names from user, store them into linked list collection. Display the names in Ascending order.
12)WAP a java program to accept string from a user, if its length is less than 6,then throw user defined exception “Invalid String “otherwise display the string in upper case.

13)WAP which accepts a string from user and display it in its reverse case.

14)WAP using swing that accepts item name, item quantity and price and display total amount as an output(in separate textbox).

15)Create a package vehicle which will have two classes-Two wheeler and four wheeler. Two wheeler with method display (CC,Price),four wheeler with method display(reg.no,reg.year).

16)Write a java program to display “Welcome to Applet” with Font-Verdana,Foreground Color-Red, Background-Yellow on the frame.

17)WAP to copy the contents of  one file into the another file, while copying change the case of alphabets and replace all the digits by $ in target file.[Use command line argument]

18)Define an abstract class shape with abstract method area() and volume().WAP to calculate area and volume of cone and cylinder.

19)WAP to accept an age from the user, if age is less than 18 then throw “Invalid age “user defined exception

20)WAP to accept the details of ‘n’ students(same,Sper)from the user, store them into the hashtable and displays the student names having maximum Sper.

21)WAP to accept ‘n’ nos through the command line and store all even nos and all odd nos in to the different arrays and display both arrays.

22)WAP to design a screen using awt that will take a username and password. If the user name and password are not same, raise an exception with appropriate message. User can use clear button to clear the Text fields.

23)WAP to accept name from the user. If the name contains a non alphabetical character ,raise an Exception “InvalidNameException”

24)WAP to accept n numbers from the command line and display in ascending order.

25)WAP a package StrPack which has 2 classes Concat and compare.concat class has a method to concarenate 2 strings and compare class has a method to compare 2 strings.Display appropriate messages.
26)Accept 2 numbers as input to the Applet using PARAM tag and display the addition of the two numbers. Accept names from the command line and add them to nthe Linkedlist.Also display the Linked list

27)WAP to count the number of words ,lines and characters in a line

28)Write an awt application that contains a frame and 2 buttons “Red” and “Blue” on click of the button give respective color to the frame.

29)WAP using swing which consist one drop down list with different font style and one textbox select font and display text in textbox in given font style.

30)Write a program to input a line of text and find out longest word in inputted tex(eg I/P Today is my practical exam O/P practical)

31)Define an abstract class Hospital with protected members id and name. Define a parameterized constructor. Define one subclass doctor with member department. create n objects of Doctor and display all details.

32)WAP to accept email address of a user and throw a user defined exception “Invalid Email Exception” if it does not contain @symbol.

33)WAP to accept ‘n’ movie names from the user: Insert into array list and display the contents of same array list, also remove first and last elements and display results.

34)WAP which accepts n integers as command line argument. Check the inserted number is prime or not if it is prime store t in an array and display the elements of array.

35)Create a package Bollywood which has 2 classes Movie and Actor.movie has 2 methods accept() and display() and Actor has two methods accept () and display().Display the information using Bollywood package.

36)WAP  to read the content of Imp.txt.Display the content of file in encoded format.(Use command line argument)

37)WAP to display the alternate characters of a file.

38)WAP
Enter a String
Resultant String