0% found this document useful (0 votes)
19 views10 pages

Oopj Summary

Object-oriented programming organizes code into objects and emphasizes encapsulation, inheritance, and polymorphism. Key features include classes, objects, inheritance, polymorphism, and abstraction. The Java development kit includes tools for developing Java applications, while the runtime environment executes Java bytecode applications.

Uploaded by

prpattanaik2003
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)
19 views10 pages

Oopj Summary

Object-oriented programming organizes code into objects and emphasizes encapsulation, inheritance, and polymorphism. Key features include classes, objects, inheritance, polymorphism, and abstraction. The Java development kit includes tools for developing Java applications, while the runtime environment executes Java bytecode applications.

Uploaded by

prpattanaik2003
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
You are on page 1/ 10

Q1 Explain OOP concept:

Object-Oriented Programming (OOP) is a programming paradigm that organizes code into objects, which are instances of
classes. It emphasizes encapsulation, inheritance, and polymorphism to model real-world entities and their interactions.

Q2 Define features of OOP:

The key features of OOP are encapsulation, inheritance, and polymorphism. Encapsulation involves bundling data and
methods that operate on that data into a single unit (class). Inheritance allows a class to inherit properties and behaviors
from another class. Polymorphism enables objects to be treated as instances of their parent class, promoting flexibility and
reusability.

Q3 What is class and Object:

A class is a blueprint or template that defines the structure and behavior of objects. An object is an instance of a class,
representing a tangible or conceptual entity with its own state and behavior.

Q4 What is JDK and JRE:

JDK (Java Development Kit) is a software development kit that includes tools for developing, debugging, and monitoring
Java applications. JRE (Java Runtime Environment) is the runtime environment where Java applications are executed. It
includes the JVM (Java Virtual Machine) and core libraries.

Q5 What is JVM:

JVM (Java Virtual Machine) is a virtual machine that executes Java bytecode. It abstracts the underlying hardware and
provides a runtime environment for Java programs, enabling platform independence.

Q6 Explain JVM architecture:

JVM architecture consists of classloader, memory area (heap, stack, method area), execution engine, native method
interface, and Java Native Interface (JNI). Classloader loads classes, the memory area manages memory, the execution
engine interprets and executes bytecode, and JNI facilitates interaction with native code.

Q7 Explain compilation process in Java:

Java source code is compiled into bytecode by the Java compiler. This bytecode is platform-independent and is then
interpreted or compiled at runtime by the JVM.

Q8 How does a Java program execute:

Java programs are executed by the JVM. The JVM loads the bytecode, performs verification, and then executes the
program. During execution, the JVM manages memory, handles exceptions, and ensures platform independence.

Q9 Explain different versions of JDK:

Different versions of JDK (Java Development Kit) include JDK 5, JDK 6, JDK 7, JDK 8, JDK 9, and so on. Each version introduces
new features, improvements, and updates to the Java programming language.

Q10 What are primitive data types in Java:

Primitive data types in Java include int, float, double, char, boolean, byte, short, and long. They store simple values directly.

Q11 What are operators? Explain:

Operators in Java perform operations on variables and values. They include arithmetic operators (+, -, *, /), relational
operators (>, <, ==, !=), logical operators (&&, ||, !), bitwise operators, assignment operators, and more.

Q12 Explain control structures:

Control structures in Java include decision-making structures (if-else, switch) and looping structures (for, while, do-while).
They control the flow of program execution based on conditions.
Q13 What are conditional statements? Explain with an example:

Conditional statements like if, else if, and else allow the execution of different code blocks based on certain conditions. For
example:

java

int num = 10;

if (num > 0) {

System.out.println("Positive number");

} else if (num < 0) {

System.out.println("Negative number");

} else {

System.out.println("Zero");

Q14 What is typecasting? Explain with an example:

Typecasting involves converting one data type to another. For example:

java

double myDouble = 10.5;

int myInt = (int) myDouble; // Explicit typecasting from double to int

Q15 Explain different types of jumping statements:

Jumping statements in Java include break, continue, and return. They alter the flow of control within loops and methods.

Q16 What is a reference data type? Explain different types:

Reference data types store references (memory addresses) to objects. Examples include classes, interfaces, arrays, and
enumerations.

Q17 Explain 2D and multidimensional array:

A 2D array in Java is an array of arrays, providing a grid-like structure. A multidimensional array extends this concept to
more than two dimensions.

Q18 What are command-line arguments?

Command-line arguments are values passed to a program when it is executed from the command line. They allow input to
be provided to the program at runtime.

Q19 What is the Scanner class? Explain different methods:

Scanner class in Java is used for taking user input. Common methods include nextInt(), nextDouble(), nextLine(), etc.

Q20 Explain System.in:

System.in is an InputStream object in Java that represents the standard input stream, typically connected to the console. It
is used with classes like Scanner to read input from the keyboard.

Q21 Define constructor with different variants:

Constructors in Java are special methods used to initialize objects. Different variants include:

- Default Constructor: No parameters.

- Parameterized Constructor: Accepts parameters.

- Copy Constructor: Constructs an object by copying values from another object.


Q22 What is constructor overloading?

Constructor overloading is having multiple constructors within a class, each with a different set of parameters. This provides
flexibility when creating objects.

Q23 Explain the following keywords:

- this: Refers to the current instance of the class.

- super: Refers to the immediate parent class.

- final: Indicates that a variable, method, or class cannot be further modified.

- public, private, protected: Access modifiers defining visibility.

- finally: A block of code that is always executed, whether an exception is thrown or not.

- abstract: Used to declare abstract classes or methods.

Q24 What is polymorphism? Explain method overriding and overloading:

Polymorphism allows objects of different types to be treated as objects of a common type. Method overriding occurs when
a subclass provides a specific implementation for a method already defined in its superclass. Method overloading involves
having multiple methods with the same name but different parameters within the same class.

Q25 What is abstraction? Explain interface and abstract with an example:

Abstraction is the concept of hiding implementation details and showing only essential features. An abstract class can have
abstract methods and concrete methods, while an interface contains only abstract methods. For example:

abstract class Shape {

abstract void draw();

interface Drawable {

void draw();

Q26 What is inheritance? Explain with an example:

Inheritance allows a class to inherit properties and behaviors from another class. For example:

class Animal {

void eat() {

System.out.println("Animal is eating");

class Dog extends Animal {

void bark() {

System.out.println("Dog is barking"); } }

Q27 Differentiate checked and unchecked exceptions:

Checked exceptions are checked at compile-time and must be handled using try-catch or declared using throws. Unchecked
exceptions (RuntimeExceptions) are not checked at compile-time.
Q28 What is the significance of polymorphism?

Polymorphism enhances flexibility and code reusability by allowing objects to be treated as instances of their parent class.
This simplifies code and promotes a clean design.

Q29 What are command line arguments?

Command-line arguments are values passed to a program when it's run from the command line. They allow the user to
input data into the program at runtime.

Q30 What is a jump statement? Explain with an example.

Jump statements in Java alter the flow of control. For example, break is used to exit a loop prematurely:

for (int i = 0; i < 5; i++) {

if (i == 3) {

break; // Exits the loop when i equals 3

System.out.println(i);

Q31 Explain immutable String:

In Java, Strings are immutable, meaning their values cannot be changed after they are created. Any operation that appears
to modify a String actually creates a new String.

Q32 Explain auto-boxing and unboxing:

Auto-boxing is the process of converting a primitive data type to its corresponding wrapper class (e.g., int to Integer).
Unboxing is the reverse process, converting the wrapper class object back to its primitive data type.

Q33 What is a class variable? Explain with an example:

A class variable is a variable declared within a class, outside any method, and is shared by all instances of the class.
Example:

class MyClass {

static int count = 0; // Class variable

MyClass() {

count++;

Q34 Differentiate String, StringBuffer, StringTokenizer:

- String: Immutable, constant value.

- StringBuffer: Mutable, allows modifications to the content.

- StringTokenizer: Used for tokenizing strings into substrings based on specified delimiters.

Q35 What is an inner class?

An inner class is a class defined within another class. It can access the outer class's members, and the outer class can access
the inner class's members.

Q36 What is an Applet?

An applet is a small Java program that runs within a web browser. It is typically used to create interactive web applications.
Q37 What is event handling?

Event handling in Java involves responding to user-generated events like button clicks or mouse movements. This is
achieved through event listeners and handlers.

Q38 What is a wrapper class?

Wrapper classes in Java provide a way to use primitive data types as objects. They include classes like Integer, Double, and
Boolean.

Q39 What is an exception?

An exception is an event that occurs during the execution of a program and disrupts the normal flow of instructions.
Exceptions need to be handled using try-catch blocks.

Q40 Explain try, catch, and finally:

- try: The block of code where an exception might occur.

- catch: The block of code that handles the exception if it occurs.

- finally: The block of code that is always executed, whether an exception occurs or not. It's often used for cleanup
operations.

Q41 Explain generic catch:

A generic catch block catches any exception, providing a common handling mechanism. However, it might make it
challenging to identify the specific exception type.

Q42 Explain component and container hierarchy:

In Java, UI components are organized in a hierarchy. Components like buttons and text fields are part of containers like
panels. Containers can hold other containers or components, forming a hierarchy.

Q43 What is multithreading?

Multithreading is the concurrent execution of two or more threads to maximize CPU utilization. Threads are independent
paths of execution within a program.

Q44 What is a thread?

A thread is the smallest unit of execution in a program. Multithreading allows multiple threads to run concurrently, sharing
resources and improving overall performance.

Q45 Explain different techniques to create a thread:

Threads in Java can be created by extending the Thread class or implementing the Runnable interface. Additionally, the
ExecutorService framework and the Callable interface can be used.

Q46 What is currentThread()?

currentThread() is a method in the Thread class that returns a reference to the currently executing thread object.

Q47 Differentiate join() and sleep():

- join(): Waits for a thread to terminate before moving on to the next operation.

- sleep(): Pauses the execution of the current thread for a specified duration.

Q48 What is a daemon thread?

A daemon thread in Java is a thread that runs in the background, providing support to non-daemon threads. When all non-
daemon threads finish, the program terminates, regardless of whether daemon threads are still running.

Q49 What is an inner class?

An inner class is a class defined within another class. It can access the outer class's members, and the outer class can access
the inner class's members.
Q50 Explain different mechanisms for event handling:

Event handling in Java can be achieved through the observer pattern, where listeners are registered to handle specific
events. Alternatively, the listener interfaces provided by Java (e.g., ActionListener) can be implemented to respond to
events.

Q51 What is AWT?

AWT (Abstract Window Toolkit) is a set of graphical user interface (GUI) components provided by Java. It includes buttons,
text fields, and other components to create windowed applications.

Q52 What is an adapter class? Explain with an example:

An adapter class in Java is a class that provides default implementations for listener interfaces so that you can choose to
override only the methods you need. For example:

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

class MyMouseListener extends MouseAdapter {

public void mouseClicked(MouseEvent e) {

System.out.println("Mouse Clicked");

Q53 Explain applet life cycle:

The life cycle of an applet in Java involves methods like init(), start(), stop(), and destroy(). These methods are called at
various stages of an applet's execution.

Q54 What is JFC?

JFC (Java Foundation Classes) is a collection of Java APIs for building rich desktop applications. Swing, part of JFC, provides
advanced GUI components.

Q55 Explain JTextArea and JTextField:

- JTextArea: A multi-line text area where users can input or view larger amounts of text.

- JTextField: A single-line text field for user input.

Q56 Explain Collection and Collections:

- Collection: An interface that represents a group of objects, often used to group objects for manipulation.

- Collections: A utility class in Java that provides various methods for working with collections, such as sorting and
searching.

Q57 Differentiate AWT and Swing:

AWT is the older GUI toolkit in Java, while Swing is part of the newer Java Foundation Classes (JFC). Swing provides more
advanced and customizable GUI components compared to AWT.

Q58 What is an adapter class?

An adapter class in Java provides default implementations for listener interfaces, allowing you to choose which methods to
override. It simplifies event handling.

Q59 Explain List interface:

The List interface in Java is part of the Java Collections Framework and represents an ordered collection of elements. It
allows duplicate elements and provides methods for adding, removing, and accessing elements by index.
Q60 What is JavaFX?

JavaFX is a platform for creating and delivering desktop applications. It provides a rich set of UI controls, graphics, media,
and more.

Q61 What is a scene in JavaFX?

In JavaFX, a Scene represents the content inside a stage. It acts as a container for all the visual elements that make up a user
interface.

Q62 Explain different mechanisms for event handling:

Event handling in Java can be achieved using various mechanisms, including implementing listener interfaces (e.g.,
ActionListener), using anonymous inner classes, and leveraging lambda expressions in newer Java versions.

Q63 Differentiate AWT and Swing:

AWT (Abstract Window Toolkit) is an older GUI toolkit in Java, while Swing is part of the Java Foundation Classes (JFC) and
provides more advanced and customizable GUI components compared to AWT.

Q64 Why is a Swing-based application lightweight?

Swing-based applications are lightweight because they use their own set of components instead of relying on the host
operating system's components. This leads to consistent behavior across different platforms.

Q65 Differentiate List, Set, and Map:

- List: An ordered collection that allows duplicate elements.

- Set: An unordered collection that does not allow duplicate elements.

- Map: A collection of key-value pairs, where each key is associated with exactly one value.

Q66 Explain Bean class:

In Java, a Bean class is a class that follows certain conventions, such as providing a default constructor and getter and setter
methods. Beans are often used in JavaBeans, a reusable software component model.

Q67 Explain setter and getter methods of a class:

Setter methods are used to set the values of private variables in a class, and getter methods are used to retrieve those
values. They are part of the encapsulation concept in OOP.

Q68 What is serialization?

Serialization in Java is the process of converting an object's state into a byte stream. This stream can be saved to a file or
transmitted over a network, and later deserialized to recreate the object.

Q69 Explain FileInputStream and FileOutputStream:

FileInputStream is used to read data from a file, and FileOutputStream is used to write data to a file in Java.

Q70 Differentiate Byte and Char stream:

- Byte streams (InputStream and OutputStream): Deal with raw binary data.

- Char streams (Reader and Writer): Deal with character data and automatically handle character encoding.

Q71 What is BufferedReader class?

BufferedReader in Java is used to read text from a character-based input stream with buffering. It provides more efficient
reading of characters by storing them in a buffer.

Q72 Explain predefined streams in Java:

Predefined streams in Java include System.in, System.out, and System.err. They represent the standard input, standard
output, and standard error streams, respectively.
Q73 Explain features of Java:

Some features of Java include platform independence, object-oriented programming, strong type-checking, automatic
memory management (garbage collection), and a rich set of APIs.

Q74 What is a static and instance block? Explain with an example:

- Static block: Executed when the class is loaded. Example:

static {

System.out.println("Static block");

- Instance block: Executed when an object is created. Example:

System.out.println("Instance block");

Q75 What is a deadlock?

A deadlock in Java occurs when two or more threads are blocked forever, each waiting for the other to release a lock. It can
lead to a complete halt in the program.

Q76 Differentiate yield() and join() method:

- yield(): Suggests that the current thread give up its execution to let other threads run. It's a hint to the scheduler.

- join(): Waits for the specified thread to finish its execution before the current thread resumes.

Q77 What is ArrayList? Explain with an example:

ArrayList is a dynamic array implementation in Java. It can dynamically grow or shrink in size. Example:

import java.util.ArrayList;

public class Example {

public static void main(String[] args) {

ArrayList<String> list = new ArrayList<>();

list.add("Java");

list.add("Python");

System.out.println(list); // Output: [Java, Python] } }

Q78 Differentiate Multithreading and multitasking:

- Multithreading: Concurrent execution of multiple threads in a single process.

- Multitasking: Concurrent execution of multiple processes or tasks on a computer.

Q79 What is the collection framework?

The Java Collections Framework provides a set of interfaces and classes for handling collections of objects. It includes
implementations like ArrayList, LinkedList, HashSet, etc.

Q80 How is an inner class used for event handling?

Inner classes are often used in event handling to encapsulate the code related to a specific event listener. This promotes
better organization and encapsulation of the code.
Q81 What is an anonymous inner class?

An anonymous inner class in Java is a class without a name that is defined and instantiated at the same time. It's often used
for one-time use, such as implementing an interface or extending a class.

Q82 What is thread priority?

Thread priority in Java is an integer value associated with a thread that indicates its priority level. Higher priority threads are
scheduled to run before lower priority threads.

Q83 Explain different thread prevention methods:

Thread prevention methods include using synchronization mechanisms like locks, semaphores, and the synchronized
keyword. These methods prevent multiple threads from accessing shared resources concurrently.

Q84 What is data abstraction?

Data abstraction is the process of hiding the implementation details and showing only the essential features of an object. In
Java, abstract classes and interfaces are used to achieve abstraction.

Q85 What is data hiding?

Data hiding is an OOP concept where the internal details of an object are hidden and only the necessary details are
exposed. It is achieved through access modifiers like private, protected, and public.

Q86 What is LayoutManager? Explain:

LayoutManager in Java is an interface that provides a way to arrange and manage components in a container. It controls
how components are displayed within a container.

Q87 Differentiate Instance block and Static block:

- Instance block: Executed when an object is created. Associated with an instance of the class.

- Static block: Executed when the class is loaded. Associated with the class itself.

Q88 What is Object class?

The Object class is the root class for all Java classes. Every class in Java is implicitly a subclass of Object. It provides methods
like equals(), hashCode(), and toString().

Q89 What is object cloning?

Object cloning in Java is the process of creating an exact copy of an object. It can be achieved by implementing the
Cloneable interface and overriding the clone() method.

Q90 What is an inner class? Explain static inner and anonymous inner class:

- Static inner class: A nested class declared as static. It can be instantiated without creating an instance of the outer class.

- Anonymous inner class: A class without a name, defined and instantiated at the same time. Often used for one-time use.

Q91 Explain the use of the following methods:

- Integer.parseInt(): Converts a string to an integer.

java

String str = "123";

int num = Integer.parseInt(str);

- Float.parseFloat(): Converts a string to a float.

java

String str = "123.45";

float num = Float.parseFloat(str);


Q92 What is polymorphism? How to implement polymorphism?

Polymorphism in Java allows objects of different types to be treated as objects of a common type. It can be implemented
through method overloading and method overriding.

Q93 Differentiate final and finally:

- final: A keyword used to declare a constant variable, a method that cannot be overridden, or a class that cannot be
inherited.

- finally: A block of code that is always executed, whether an exception is thrown or not. Used in exception handling.

Q94 Explain the following methods with the help of the Applet class:

- drawRect(): Draws a rectangle.

- drawOval(): Draws an oval.

- fillRect(): Fills the interior of a rectangle.

- fillOval(): Fills the interior of an oval.

import java.applet.Applet;

import java.awt.Graphics;

public class MyApplet extends Applet {

public void paint(Graphics g) {

g.drawRect(10, 10, 50, 50);

g.drawOval(70, 10, 50, 50);

g.fillRect(130, 10, 50, 50);

g.fillOval(190, 10, 50, 50); } }

Q95 What is the paint() method? Explain with an example:

The paint() method in Java is called by the system to request that the applet or component repaint itself. It's commonly
overridden in applets.

import java.applet.Applet;

import java.awt.Graphics;
Q99 What is a deadlock?
public class MyApplet extends Applet {
A deadlock occurs when two or more threads
public void paint(Graphics g) { are blocked, each waiting for the other to
release a lock. It results in a state where no
g.drawString("Hello, Java!", 20, 20); } } thread can proceed.
Q96 Differentiate TextField and JTextField:

- TextField: A class in AWT used to create a single-line text input field.

- JTextField: A class in Swing (part of JFC) used for the same purpose but with more features and customization options.

Q97 What is JavaFX?

JavaFX is a set of graphics and media packages that enables developers to design, create, test, debug, and deploy rich client
applications.

Q98 Differentiate Panel and JPanel:

- Panel: A class in AWT used as a container for components.

- JPanel: A class in Swing (part of JFC) used for the same purpose but with more features and customization options.

You might also like