0% found this document useful (0 votes)
3 views4 pages

Java Programming Concepts Explained

The document provides a comprehensive overview of various Java concepts including the purpose of the final keyword, the javap tool, array declarations, inheritance, exception handling, and GUI components. It outlines key differences between classes, methods, and data types, as well as the roles of various Java keywords and classes. Additionally, it covers topics such as method overloading, runtime polymorphism, and the distinction between Swing and AWT.

Uploaded by

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

Java Programming Concepts Explained

The document provides a comprehensive overview of various Java concepts including the purpose of the final keyword, the javap tool, array declarations, inheritance, exception handling, and GUI components. It outlines key differences between classes, methods, and data types, as well as the roles of various Java keywords and classes. Additionally, it covers topics such as method overloading, runtime polymorphism, and the distinction between Swing and AWT.

Uploaded by

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

Q1a) Purpose of final keyword when applied to variables

➡■ Makes the variable constant (value cannot be changed once assigned).

Q1b) Purpose of javap tool


➡■ Disassembler tool that shows bytecode and method/field details of compiled .class files.

Q1c) 1D array declaration in Java


➡■ int arr[] = new int[5];

Q1d) Object class in Java


➡■ Parent (superclass) of all classes in Java; every class directly or indirectly inherits it.

Q1e) Wrapper class in Java


➡■ Converts primitive data types into objects (e.g., Integer, Double).

Q1f) Role of extends keyword


➡■ Used for inheritance — one class inherits properties/methods of another.

Q1g) Purpose of BufferedReader class


➡■ Reads text from input stream efficiently using buffering.

Q1h) Define Exception


➡■ An event that disrupts the normal flow of program execution.

Q1i) Package for event handling


➡■ [Link]

Q1j) Two Swing GUI components


➡■ JButton, JTextField

Q1k) What is Bytecode?


➡■ Intermediate code generated by Java compiler, executed by JVM.

Q1l) Characteristics of Inheritance


➡■ 1) Code reusability 2) Method overriding

Q1m) Use of this keyword


➡■ Refers to current object, used to access instance variables, methods, or constructors.

Q1n) Is constructor overloading possible?


➡■ Yes, by having multiple constructors with different parameters.

Q1o) What is AWT?


➡■ Abstract Window Toolkit, used for GUI in Java.

Q1p) Use of Adapter class


➡■ Provides default implementation of listener interfaces, so programmer overrides only required
methods.

Q1q) Types of Checked Exception


➡■ IOException, SQLException

Q1r) Scanner vs BufferedReader


➡■ Scanner parses primitives, slower; BufferedReader reads text line by line, faster for bulk input.

Q1s) Use of toString() method


➡■ Converts object into string representation.

Q1t) Any two Event classes


➡■ ActionEvent, KeyEvent

Q1u) Two datatypes in Java


➡■ int, float

Q1v) Use of abstract keyword


➡■ To define abstract classes/methods.

Q1w) Interface
➡■ Blueprint of a class with abstract methods.

Q1x) Two Reader classes


➡■ FileReader, BufferedReader

Q1y) End-of-file check


➡■ read() returns -1.

Q1z) Panel in AWT


➡■ Container used to hold components.

Q1aa) Two Layout Managers


➡■ FlowLayout, BorderLayout

Q1ab) Can final methods be overridden?


➡■ No, final methods cannot be overridden.

Q1ac) Listener in Java


➡■ Object that waits for an event (e.g., ActionListener, KeyListener).
Q1ad) Command line arguments
➡■ Passed via String[] args in main().

Q1ae) throw vs throws


➡■ throw: used to throw an exception; throws: declares exceptions in method signature.

Q1af) Purpose of javac


➡■ Java compiler (compiles .java to .class).

Q2a) Constructors in Java + Overloading + this keyword


➡■ Constructor initializes objects; overloading allows multiple constructors with different
parameters; this calls another constructor in the same class.

Q2b) Example program using Inheritance and super keyword


➡■ Dog extends Animal; Dog constructor calls super() to invoke Animal constructor.

Q2c) FileReader vs FileWriter


➡■ FileReader reads char data, FileWriter writes char data.

Q2d) Layouts in Swing


➡■ FlowLayout arranges left-to-right; BorderLayout divides into 5 regions.

Q2e) Command line arguments in Java


➡■ Passed during execution, accessed via args[] in main().

Q3a) Object vs Reference variable


➡■ Object is real entity created with new; Reference variable stores object address.

Q3b) Methods of Character wrapper class


➡■ isDigit(), isLetter().

Q3c) Use of length property (arrays)


➡■ Returns number of elements in array; [Link].

Q3d) Use of JFileChooser


➡■ Allows users to choose files/directories.

Q3e) Runtime Polymorphism


➡■ Achieved via method overriding (Animal → Dog example).

Q4a) Method Overloading vs Overriding


➡■ Overloading: same name, different params, compile-time; Overriding: same signature in
subclass, runtime.
Q4b) Access Specifiers
➡■ public, private, protected, default.

Q4c) Marker Interface


➡■ Interface with no methods (e.g., Serializable).

Q4d) Exception Types


➡■ Checked and Unchecked exceptions.

Q4e) Swing vs AWT


➡■ Swing lightweight, platform-independent, rich GUI; AWT heavyweight, platform-dependent.

Q5a) Constructor types


➡■ Default, Parameterized, Copy constructors.

Q5b) Class vs Instance variables


➡■ Class variables declared static, shared; Instance variables unique per object.

Q5c) Purpose of abstract keyword


➡■ Used to define abstract classes/methods.

Q5d) Top of Exception Hierarchy


➡■ Class: Throwable; Interface: Serializable.

Q5e) JFileChooser syntax


➡■ JFileChooser chooser = new JFileChooser(); [Link](null);

FileReader FileWriter
Reads data from files. Writes data to files.
Character-based input. Character-based output.
Returns int (character code). Writes single char/array/string.
Example: new FileReader('[Link]'); Example: new FileWriter('[Link]');

You might also like