0% found this document useful (0 votes)
16 views3 pages

Java Basics: Keywords, Classes, and Methods

The document provides an overview of various Java concepts, including the purpose of the javap tool, data types, the 'this' keyword, toString() method, abstract keyword, interfaces, Reader classes, EOF checking, Panel, Layout Managers, final keyword, 1D array declaration, Object class, wrapper classes, extends keyword, BufferedReader class, exceptions, event handling package, and GUI components in Swing.

Uploaded by

yashkhalate672
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Java Basics: Keywords, Classes, and Methods

The document provides an overview of various Java concepts, including the purpose of the javap tool, data types, the 'this' keyword, toString() method, abstract keyword, interfaces, Reader classes, EOF checking, Panel, Layout Managers, final keyword, 1D array declaration, Object class, wrapper classes, extends keyword, BufferedReader class, exceptions, event handling package, and GUI components in Swing.

Uploaded by

yashkhalate672
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

a) What is the purpose of javap?

javap is a Java disassembler used to view the bytecode, methods, fields, and
internal structure of a compiled .class file.

b) List any two datatypes in Java.


int

float
(Other examples: char, double, boolean, byte, short, long, String)

c) Write the purpose of this keyword.

this keyword is used to refer to the current class object.


It helps to distinguish between instance variables and local variables with same
names.

d) What is the use of toString()?

toString() method returns string representation of an object.


It is used for displaying object values in readable form.

e) Write the use of abstract keyword.

abstract is used to declare:

Abstract classes (incomplete classes)

Abstract methods (methods without body)


It supports polymorphism and abstraction.

f) Define interface.

An interface is a collection of abstract methods and constants.


It is used to achieve multiple inheritance and define common behavior for classes.

g) List any two Reader Classes.


FileReader

BufferedReader
(Other examples: InputStreamReader, CharArrayReader)

h) How to check End of File (EOF)?

EOF is checked when a read() method returns -1.


Example:

int data = [Link]();if(data == -1) // EOF reached

i) What is Panel?

A Panel is a container component in AWT used to hold and organize UI


components like buttons, labels, text fields.

j) Give names of any two Layout Managers.


FlowLayout

BorderLayout

a) What is the purpose of the final keyword when


applied to variables?

When final is used with variables, it means the variable becomes constant and its
value cannot be changed once assigned.

b) What is the purpose of the javap tool in Java?

javap is a Java disassembler tool used to display bytecode, methods, fields, and
internal structure of a compiled .class file.

c) How is a 1D array declared in Java?

A one-dimensional array is declared as:

datatype arrayname[]; // or
datatype[] arrayname;
Example: int arr[] = new int[5];

d) What is the Object class in Java?

Object class is the superclass of all classes in Java.


Every class directly or indirectly inherits from the Object class.

e) What is a wrapper class in Java?

Wrapper classes are classes that convert primitive data types into objects.
Example: Integer, Float, Double, Boolean.

f) What is the role of the extends keyword in Java?

extends is used to inherit properties and methods from one class to another.
It supports single inheritance in Java.

g) What is the purpose of BufferedReader class?

BufferedReader is used to read text from input streams efficiently.


It reads data line by line and improves performance by buffering input internally.

h) Define Exception.

Exception is an unwanted or unexpected event that occurs during program


execution and disrupts normal program flow.

i) Name the package used for event handling in Java.


[Link]

j) Name any two GUI components used in Swing.


JButton

JLabel
(Other examples: JTextField, JCheckBox, JComboBox, JFrame)

You might also like