The document contains a comprehensive list of questions and programming tasks related to Java, covering topics such as Java features, applet life cycles, thread management, exception handling, and file operations. It includes multiple sub-questions that require explanations, code examples, and the implementation of various Java concepts. The questions are organized into six main sections, each focusing on different aspects of Java programming.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
1 views
Java Question Bank
The document contains a comprehensive list of questions and programming tasks related to Java, covering topics such as Java features, applet life cycles, thread management, exception handling, and file operations. It includes multiple sub-questions that require explanations, code examples, and the implementation of various Java concepts. The questions are organized into six main sections, each focusing on different aspects of Java programming.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8
Main Question 1 – 56 Sub-questions (Numbered)
1. Enlist any four features of java.
2. Write the use of ‘this’ keyword. 3. Write the use of super keyword. 4. Explain the use of throw and throws. 5. Enlist the life cycle methods of Applet. 6. Give two methods of file class. 7. Write the use of <PARAM> tag in an applet. 8. State the significance of Java Virtual Machine (JVM) in the Java programming environment. 9. Define array. List its types. 10. State use of finalize() method with its syntax. 11. Define the interface in Java. Write the syntax. 12. Define thread. Mention 2 ways to create thread. 13. Write syntax of drawRect(). 14. Give the use of <PARAM> tag in applet. 15. Enlist any two logical operators and two bitwise operators. 16. Define constructor. 17. Write down the syntax of array declaration, initialization. 18. List out different ways to access package from another package. 19. Differentiate between starting thread with run() method and start() method. 20. State the classes that can an applet extend. 21. Give syntax to open a file using InputStream class. 22. Define the terms with example i) Class ii) Object 23. Enlist any two access specifier with syntax. 24. Give a syntax to create a package and accessing package in java. 25. Give a syntax of following thread method i) Notify ( ) ii) Sleep ( ) 26. Give a syntax of <PARAM> tag to pass parameters to an applet. 27. Define stream class and list types of stream class. 28. Give use of garbage collection in java. 29. List any eight features of Java. 30. State use of finalize() method with its syntax. 31. Name the wrapper class methods for the following: (i) To convert string objects to primitive int. (ii) To convert primitive int to string objects. 32. List the types of inheritances in Java. 33. Write the syntax of try-catch-finally blocks. 34. Give the syntax of <PARAM> tag to pass parameters to an applet. 35. Define stream class. List its types. 36. Define Constructor. List its types. 37. Define Class and Object. 38. List the methods of File Input Stream Class. 39. Define error. List types of error. 40. List any four Java API packages. 41. Define array. List its types. 42. List access specifiers in Java. 43. Enlist the logical operators in Java. 44. Give the syntax and example for the following functions i) min ( ) ii) Sqrt ( ) 45. Define the interface in Java. 46. Enlist any four inbuilt packages in Java. 47. Explain any two methods of File Class. 48. Write syntax of ellipse. 49. Enlist any four compile time errors. 50. State any four relational operators and their use. 51. Enlist access specifiers in Java. 52. Explain constructor with suitable example. 53. List the types of inheritance which is supported by java. 54. Define thread. Mention 2 ways to create thread. 55. Distinguish between Java applications and Java Applet (Any 2 points) 56. Draw the hierarchy of stream classes.
Main Question 2 – 32 Sub-questions (Numbered)
1. Write a program using sqrt( ) and pow( ) to calculate the square root and power of given number. 2. Write a program to accept four numbers from user using command line arguments and print the smallest number. 3. Explain two ways of creating threads in java with suitable example. 4. Give the usage of following: i) setColor() ii) getColor() iii) setForeground() iv) setBackground() 5. Explain the concept of platform independence in Java and discuss how it is achieved. Give example to illustrate the concept. 6. What happens if you don't define any constructor in a class? Can you still create objects of that class? Explain with example. 7. Write a Java program in which thread A will display the even numbers between 1 to 50 and thread B will display the odd numbers between 1 to 50. After 3 iterations thread A should go to sleep for 500 ms. 8. Explain multilevel inheritance with example. 9. Write a program to display ASCII value of a number 9. 10. Write a program to sort the elements of an array in ascending order. 11. Define Thread. Draw life cycle of Thread. 12. Write a program to read a file and then count number of words. 13. Describe type casting in java with example. 14. Differentiate between string and string buffer class (any four points). 15. Write a program to create a user defined exception in java. 16. Write a program for reading and writing character to and from the given files using character stream classes. 17. Explain the concept of platform independence and portability with respect to Java language. 18. Explain the types of constructors in Java with suitable example. 19. Explain the two ways of creating threads in Java. 20. Distinguish between Input stream class and output stream class. 21. Differentiate between String and String Buffer. 22. Define a class circle having data members pi and radius. Initialize and display values of data members also calculate area of circle and display it. 23. Define exception. State built-in exceptions. 24. Write syntax and example of : 1) drawRect() 2) drawOval() 25. Write a Java program to find out the even numbers from 1 to 100 using for loop. 26. Explain any four visibility controls in Java. 27. Explain single and multilevel inheritance with proper example. 28. Explain exception handling mechanism w.r.t. try, catch, throw and finally. 29. Write a program to check whether the given number is prime or not. 30. Define a class employee with data members 'empid , name and salary. Accept data for three objects and display it. 31. Describe Life cycle of thread with suitable diagram. 32. Write a program to read a file (Use character stream).
Main Question 3 – 32 Sub-questions (Numbered)
1. Write a program to copy contents of one file into another. 2. Write a program to create an exception MIN-BAL. Display warning message when balance is less than 500. 3. Define a class employee with emp_id, name, salary as data members. Accept and display data of 5 employees. 4. Explain the use of final keyword with suitable example. 5. Explain the use of super keyword in inheritance. 6. Write syntax and use of the following methods: i) drawLine() ii) drawOval() iii) drawArc() iv) drawString() 7. What are streams? Explain how streams facilitate I/O in Java. 8. Write a program for ATM functionality including withdraw, deposit and balance check. 9. Differentiate between method overloading and method overriding. 10. Draw and explain life cycle of Applet. 11. Differentiate between byte stream class and character stream class. 12. Write a program to print Armstrong numbers from 0 to 999. 13. Explain the use of package in Java with suitable example. 14. List byte stream classes. Explain InputStream and OutputStream. 15. Define interface and explain how it is implemented with example. 16. Write an applet program to draw a circle using drawOval() and a line using drawLine(). 17. List any four methods of FileInputStream class and write syntax. 18. Write a program to append the content of one file into another. 19. Write a program to read and write characters using FileReader and FileWriter. 20. Write a program to draw a chessboard using Applet. 21. Write a program to read contents from file and handle file not found exception. 22. Define a class for complex numbers and perform sum, difference and product of two complex numbers. 23. Define copy constructor with example. 24. Write a program to print Armstrong numbers between 1 to 500 using for loop. 25. Write a Java applet program to draw a polygon using drawPolygon() method. 26. Write a program to demonstrate thread synchronization in Java. 27. Write a program to handle multiple exceptions using multiple catch blocks. 28. Define a class with constructor accepting user input and displaying it. 29. Write a program to declare and use vector class and display elements using iterator. 30. Write a program to create a new file, write some text into it and read back the same. 31. Write an applet program that accepts two parameters from HTML file using <PARAM> tag and performs addition. 32. Explain garbage collection mechanism in Java with suitable example.
Main Question 4 – 40 Sub-questions (Numbered)
1. Enlist and explain any four access specifiers in Java. 2. Write a Java program using conditional operator and switch statement. 3. Write the steps to create and import a package in Java. 4. Draw life cycle of thread and explain each state. 5. Explain garbage collection in Java. 6. Write any two logical operators in Java and explain them with example. 7. Explain constructor with types and example. 8. Define interface and explain how to implement it in Java. 9. Write a program to implement hierarchical inheritance. 10. Explain implicit and explicit type conversion with example. 11. Define and explain copy constructor with example. 12. List any four font methods in Java with example. 13. Write an applet program to draw concentric circles of different color using drawOval() method. 14. Write a program to count the number of words in the file named “data.txt” using stream classes. 15. Write a Java program to check whether the given number is Armstrong number or not. 16. Write an applet program to draw a pattern using drawLine() as shown in fig. 2. 17. Write an applet program to draw a chessboard. 18. Write a program using class for complex numbers which will perform addition, subtraction and multiplication. 19. State the types of errors in Java. 20. Differentiate between error and exception. 21. Write a program using multiple catch blocks. 22. Differentiate between class and interface. 23. Explain the use of super and this keywords in constructor. 24. Define final class and final method with example. 25. Differentiate between Java Applet and Java Application. 26. Write a program to demonstrate use of String methods. 27. Explain use of package java.awt with example. 28. Write a program to read content from a file using BufferedReader. 29. Write a program to read a line using BufferedReader class and display it. 30. Write a program to find square and cube of a number using Math class. 31. Write a program for conditional compilation in Java. 32. Write a Java program using command line arguments. 33. Explain the use of static keyword with example. 34. Write a program to demonstrate propagation of exception. 35. Write a constructor in applet and explain its behavior. 36. Write a program to merge two arrays. 37. Write an applet program to draw a rectangle. 38. Write a program using RandomAccessFile to read and write data to a file. 39. Write a program demonstrating thread synchronization using synchronized method. 40. Write a program to implement multiple inheritance using interface.
Main Question 5 – 24 Sub-questions (Numbered)
1. Explain dynamic method dispatch with example. 2. Write a program to check whether the given number is Armstrong number or not. 3. Write an Applet program to accept 2 numbers using <PARAM> tag and perform arithmetic operations. 4. What is vector class? Explain any three methods of vector class with example. 5. Define interface to find simple interest and compound interest. Accept values from user using constructors and display it. 6. Write a program to throw NoMatchException if the entered string is not "India". 7. Write a Java program to copy all the elements of one array into another array. 8. Write a Java program to implement inheritance as shown in fig.1. 9. Write a Java program using two threads, one to print even numbers and second to print odd numbers between 1 to 50. Let the delay between each number be 1000 milliseconds. 10. Explain argument passing with the help of this keyword. 11. Explain the concept and use of package in Java with suitable example. 12. Write a program to handle exception using try and catch block. 13. Define a class for employee. Accept data of 5 employees and display employee having highest salary. 14. Define an interface and implement it in two classes with suitable example. 15. Write an Applet program to draw three concentric circles with different colors using drawOval() method. 16. Write a Java program to implement thread using sleep() and yield() methods. 17. Write a Java applet-based calculator using graphics methods. 18. Write a Java program to handle ArithmeticException using try- catch block. 19. Write a Java program to write and read a text file using FileOutputStream and FileInputStream. 20. Explain the use of static block in Java with example. 21. Explain different access modifiers used with package members. 22. Define abstract class. Write a program to demonstrate abstract class and method. 23. Write a program to demonstrate restriction of overriding final method in derived class. 24. Write a program to define and access final variable inside interface.
Main Question 6 – 24 Sub-questions (Numbered)
1. Draw and explain life cycle of an Applet. 2. Write a Java program using two threads. One thread should display odd numbers and the other should display even numbers from 1 to 50. 3. What is vector class? Explain any six methods of vector class. 4. Write an Applet program to draw a chessboard. 5. Define a class for complex number and perform sum, difference, and product of two complex numbers. 6. Explain the types of errors and thread priority methods in Java. 7. Write an Applet program to draw three concentric circles of different colors using drawOval() method. 8. Write an Applet program to draw a pattern using drawLine() as shown in Fig. 2. 9. Define types of constructors and write a program to demonstrate parameterized constructor. 10. Explain thread life cycle with suitable diagram and explanation. 11. Define a class for employee. Accept data of 5 employees and display employee having highest salary. 12. Write a program to handle multiple exceptions using nested try blocks. 13. Write a Java program to draw polygon, arc, and ellipse using graphics methods. 14. Write a Java program to find reverse of a number. 15. Differentiate between Java Applet and Java Application (any four points). 16. Write a Java program to read contents of a text file using character stream. 17. Write a Java program to demonstrate the use of wait() and notify() methods in thread communication. 18. Write an Applet program to generate a triangle pattern using graphics methods. 19. Write a Java program to append content to a file using BufferedWriter. 20. Write a Java program to check if a file is readable using canRead() method. 21. Explain deadlock situation in Java with suitable example. 22. Write a Java program to create and run thread using anonymous class. 23. Write an Applet program that switches background color on mouse click. 24. Differentiate between constructor overloading and method overriding with example.