Java Questions According to Topics
Java Questions According to Topics
Fundamentals of Java:
9. Write the use of the 'this' keyword. Explain the usage of the 'this'
keyword in Java and give an example to illustrate its usage and
benefits.
10. Write the use of the 'super' keyword. How can the "super"
keyword be used in inheritance? Give an example to demonstrate its
usage.
11. Write the use of the 'Final' keyword with a suitable example.
12. Explain dynamic method dispatch mechanism with a suitable
example.
13. Explain the concept of argument passing in Java and give an
example to illustrate its usage and benefits.
III. Arrays:
14. a) Define array. List its types. b) Write down the syntax of array
declaration and initialization.
15. a) Write a program to sort the elements of an array in ascending
order. b) Write a program to copy all elements of one array into
another array.
IV. Packages:
V. Inheritance:
VII. Threads:
VIII. Interfaces:
24. a) Define the interface in Java. Write the syntax. b) Describe the
interface in Java with a suitable example. c) Develop an Interest
Interface which contains Simple Interest and Compound Interest
methods and a static final field of rate 25%. Write a class to implement
those methods.
IX. Applets:
25. a) Enlist the life cycle methods of Applet. b) Explain the applet
life cycle in detail. c) Explain the applet life cycle with a neat diagram.
d) Explain the life cycle of an Applet with a suitable example.
26. a) Write the use of the <PARAM> tag in an applet. b) Give the use of
the <PARAM> tag in the applet. c) Give a syntax of the <PARAM> tag to pass
parameters to an applet. d) Design an Applet using <PARAM> tag to
accept two numbers and perform arithmetic operations.
27. a) State the classes that an applet can extend. b) Write an applet
program for the following graphics methods: i) drawOval() ii) drawLine()
c) Write a program to design an Applet showing three concentric circles
filled with three different colors. d) Write a program to draw a
chessboard in Java Applet.
28. a) Write syntax of drawRect(). b) Explain the following with
syntax: i) drawLine() ii) drawOval() iii) drawArc() iv) drawString() c)
Explain any four font methods with an example. d) Write a program to
generate the following output using the drawLine() method. (Refer to
Fig. No. 2 from the original document).
29. Give the usage of the following: i) setColor() ii) getColor() iii)
setForeground() iv) setBackground()
XII. Programs:
34. Write a program using sqrt() and pow() to calculate the square
root and power of a given number.
35. Write a program to accept four numbers from the user using
command-line arguments and print the smallest number.
36. Write a program to display the ASCII value of the number 9.
37. a) Define a class employee having data members as emp_id, name,
and salary. Accept and display the data for five employees. b) Define a
class employee with data members empid, name, and salary. Accept data
for three objects and display it. c) Write a program to define class
Employee with members as id and salary. Accept data for five
employees and display details of employees getting the highest salary.
38. Write a program which displays the functioning of an ATM
machine (Hint: Withdraw, Deposit, Check Balance, and Exit).
39. Write a program to print all the Armstrong numbers from 0 to
999.
40. Write a program to check whether the entered number is an
Armstrong number or not.
41. Write a program to print the sum, difference, and product of two
complex numbers by creating a class named "Complex" with separate
methods for each operation whose real and imaginary parts are
entered by the user.
42. Write a program to show the use of a copy constructor.