Skip to main content

Review Questions

Topic: Applet, AWT and Event Handling

1. What are Applets? How it is different from Normal java class?

2. What is the difference between Panel, Applet, Window and Frame? Can we add a Frame within a Panel?

3. Explain the Applet Life cycle. What is the importance of paint() and repaint().

4. List various methods of Graphics class. Write code snippet to draw the following shapes in Applet:
String, Rectangle, Oval, Circle, Rounded Corner Rectangle, Polygon and Polylines.

5. What do you mean by Event Handling? Explain Event Delegation Model. How will you register an event source with Listener? Write code snippet.

6. WAP to create a GUI having 4 text fields in four different sides of a frame and a button at the center. Contents of Text fields must be swapped (North<--> South and East<--> West) when the button is pressed

7. WAP to create an applet displaying a ball filled with blue color. Use event handling to move the ball with the mouse-pointer.

8. What is the difference between RadioButton and CheckBox? Write code snippet to create 2 radio buttons using AWT.

9. WAP to create a GUI containing 10 buttons in a grid with 3 rows and 4 columns.

10. List various methods of CardLayout class. WAP to demonstrate the use of CardLayout.

11. WAP using Applet to draw 3 co-centric circles filled with different colors. Write the code required to execute this applet in Web browser.

12. WAP to create a login page accepting user_id and password, migrate to a welcome page when the submit button is pressed by the user. Welcome page must display the user_id of the user.

13. List all the methods of MouseListener, MouseMotionListener, WindowListener, and KeyListener Interfaces.

=========================================================================

Topic: I/O Streams

1. What do you mean by Streams? How will you differentiate between Character Stream and Byte Stream?

2. "ObjectInputStream can be used as a substitute of DataInputStream." Do you agree with the statement? Comment.

3. What is the importance of FIle class? List any 5 methods of File class.
How will you check whether a file object represents a file or directory?
How BufferedOutputStream is more efficient than DataOutputStream?

4. What is the need of RandomAccessFIle. List any 5 methods of RandomAccessFile. Write code snippet to read the 10th integer from a file using RandomAccessFIle.

5. WAP to copy the contents of one file to another file.

6. What is the difference between InputStream and OutputStream? WAP to read alternate numbers from a file containing 100 integers using RandomAccessFile.

7. What do you mean by Serialization and De-serialization? What is transient variable?

8. What is the importance of BufferedInput/OutputStream? Write code snippets to instantiate BufferedInputStream, ObjectOutputStream and DataInputStream.

9. What are the advantages of DataInputStream over FIleInputStream? Write any 5 methods of DataOutputStream class.

10. Write a program to create a file named "copy.txt" if it does not exist. Append new data to it. Write 20 double numbers into the file using binary I/O.

========================================================================= 

Topic: Multi-threading

1. Explain Thread life-cycle with diagram. How a Thread is different from a Process? "Thread is a light-weight process" what do you mean by this statement?

2. Write any 5 Methods of Thread class with their uses.
(a) public static void start()
(b) public static void yield()
(c) public void join()
(d) public static Thread currentThread()
(e) public boolean isAlive()

3. How join method is different from yield method? WAP to demonstrate the use of join method.

4. What do you mean by Thread synchronization? What are the two ways of synchronizing a thread? What is the advantage of Synchronized block over Synchronized method in Multi-threading?

5. How will you change the name and priority of a thread? What are the possible values of Thread- Priority?

6. WAP to prompt the user to enter 2 integers A and B. Create a thread named "Demo-1" with priority 7 to display the 10 consecutive numbers starting from A with sleep time 2 seconds, and another thread named "Demo-2" to display all the positive even numbers from B to 0 in reverse order.

7. What is the need of synchronized block? How it is different from synchronized method?

8. How will you check whether a thread is terminated or not? Name the exception thrown by sleep() method.

9. WAP to create two threads named "Thread 1" and "Thread 2". Set the priorities of threads 2 and 9 respectively. Thread 1 should display the table of number i and Thread 2 should display A,B,...Z. Integer i should be entered by the user. Use sleep method for both the threads.

10. WAP to demonstrate the serialization. 


===========================================================================

 

Comments

Popular posts from this blog

Practice MCQs

  1. What will be the Output of the following code? class X{                  static int x = 1;                        static class Y {                              static int y = x++;                                static class Z                                                                       {                                                                                         static int z = ++y;                                                                        }                                               }                }   class MainClass{     public static void main(String[] rk)    {                             System.out.print(X.x);                                             System.out.print(X.Y.y);                             System.out.print(X.Y.Z.z);         } } A. 113 B. 123 C. 111 D. None of These Ans: A 2.  Which of the following statement is TRUE about t he following code? public class Outer  {    private i

Practice Set

1. Write a program to create a class Voter which contains attributes name, date_of_birth and voter_id and voter has a Voter_Card. Provide appropriate constructor to initialize all the attributes of the Voter but voter id must be assigned automatically only when the age of the voter is greater than or equal to 18 years. VoterCard is a nested class with attributes voter_id and Voter_name. Make sure that voter card is created only when user is a valid voter and if it is already created then must not be assigned the new voter id. 2. Write a program to define two interfaces UGC and AICTE both having a default method int getAdmission() to take the admission and an abstract method String payFee(). getAdmission() in UGC must ask the percentage in qualifying exam and if the percentage >= 60 then generate the registration number and return. getAdmission() is AICTE must ask the user to join the counseling after 5 days and display the date of counseling and return the counseling token numb

Mock Test - 1

1. Which of the following is a byte stream class? A. ObjectInputStream B. Writer C. PrintWriter D. Scanner Ans: A 2. Which exception is thrown by read() method in InputStream class? A. IOException B. InterruptedException C. FileNotFoundException D. None of These Ans: A 3. Which of the following class is subclass of FilterInputStream? A. InputStream B. ObjectOutputStream C. FileInputStream D. BufferedInputStream  Ans: D 4. Which of these class contains the print() and println() methods? A. System B. out C. PrintStream D. BUfferedOutputStream Ans: C 5. Which of these is a method to clear all the data present in output buffer without terminating the stream? A. clear() B. fflush() C. flush() D. close() Ans: C 6. Which of these classes defined in java.io and used for file-handling are abstract? (i) InputStream        (ii) PrintStream    (iii) Reader        (iv) FileInputStream A. Only i     B. i and ii    C. Only iii    D. i and iii Ans: D 7. What is the output of this program? class MyE