[go: up one dir, main page]

0% found this document useful (0 votes)
4 views5 pages

Java Complete Exam Flashcards

Java, developed by James Gosling in 1995, is a versatile programming language known for its portability and object-oriented principles. Key features include bytecode for platform independence, selection and iteration statements for control flow, and robust exception handling. Java also supports multithreading, inheritance, and interfaces, making it suitable for building complex applications.

Uploaded by

afmrah
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)
4 views5 pages

Java Complete Exam Flashcards

Java, developed by James Gosling in 1995, is a versatile programming language known for its portability and object-oriented principles. Key features include bytecode for platform independence, selection and iteration statements for control flow, and robust exception handling. Java also supports multithreading, inheritance, and interfaces, making it suitable for building complex applications.

Uploaded by

afmrah
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/ 5

Java Programming - Exam Flashcards

History and Evolution of Java

Java was developed by James Gosling at Sun Microsystems in 1995. Originally called Oak, it was designed

for embedded systems but evolved into a full-featured programming language for building cross-platform

applications. It became popular due to its portability, enabled by the Java Virtual Machine (JVM).

Bytecode

Bytecode is an intermediate representation of Java code, generated after compiling a Java source file. It is

platform-independent and executed by the Java Virtual Machine (JVM), enabling Java's 'write once, run

anywhere' capability.

Java Buzzwords

Java is described using several key features known as 'buzzwords':

- Simple: Easy to learn and use.

- Secure: Provides a secure execution environment.

- Portable: Platform-independent via bytecode.

- Object-Oriented: Everything is treated as an object.

- Robust: Emphasizes error checking and memory management.

- Multithreaded: Supports concurrent execution.

- Architecture-neutral: Not tied to any specific CPU architecture.

- Interpreted: Bytecode is executed by the JVM.

- High Performance: Optimized via Just-In-Time compilers.

- Distributed: Supports networking and remote object access.

- Dynamic: Adapts to evolving needs at runtime.

Object Oriented Programming (OOP)

Java uses Object-Oriented Programming principles, including:

- Encapsulation: Wrapping data and methods into a single unit (class).

- Inheritance: Creating new classes from existing ones.

- Polymorphism: Performing a single action in different ways.

- Abstraction: Hiding implementation details and exposing only functionality.


Java Programming - Exam Flashcards

Java's Selection Statements

Java provides decision-making capabilities through selection statements:

- if: Executes a block if a condition is true.

- if-else: Adds an alternate block if the condition is false.

- switch: Selects execution path based on matching case values.

Iteration Statements

Loops used to repeat code:

- for: Loop with initialization, condition, and update in one line.

- while: Loops while a condition is true.

- do-while: Executes once before checking the condition.

Jump Statements

Used for altering control flow:

- break: Exits the loop or switch.

- continue: Skips current iteration and moves to next.

- return: Exits from the method and optionally returns a value.

Class Fundamentals

Classes are blueprints for objects. They contain fields (variables) and methods (functions). Syntax:

class ClassName { ... }

Declaring Objects

To create an object: ClassName obj = new ClassName(); This allocates memory and invokes the constructor.

Constructors and this Keyword

Constructors initialize objects. They have the same name as the class and no return type. 'this' refers to the

current object and helps resolve naming conflicts.

Garbage Collection and finalize()

Java handles memory using automatic garbage collection. The finalize() method is called before an object is
Java Programming - Exam Flashcards

destroyed to release resources.

Method Overloading and Recursion

Overloading: Defining multiple methods with the same name but different parameters. Recursion: A method

calling itself for repetitive tasks.

Access Control and Static Members

Access modifiers (public, private, protected, default) control visibility. Static members belong to the class

rather than instances.

Final Keyword

Used to make variables constants, prevent method overriding, or inheritance of classes.

Inheritance Basics

Allows a new class (subclass) to inherit members from an existing class (superclass). Syntax: class Subclass

extends Superclass {}

super Keyword and Constructor Calls

super refers to the parent class. It is used to access superclass methods/constructors. Constructors in the

superclass are called before subclass constructors.

Multilevel Inheritance and Method Overriding

A class inherits from a subclass which itself inherits from another class. Overriding allows redefining a

method of the superclass in the subclass.

Dynamic Method Dispatch

Determines which method to call at runtime based on the object type. Enables polymorphism.

Abstract Classes and Final with Inheritance

Abstract classes contain abstract methods (no body) and cannot be instantiated. The final keyword prevents

further inheritance or method overriding.

Packages and Access Protection


Java Programming - Exam Flashcards

Packages group related classes. Access protection controls visibility outside the package. Use import to

access classes from other packages.

Interfaces

Defines a contract for classes. Contains abstract methods only. A class implements an interface using

'implements' keyword.

Exception Handling Fundamentals

An exception is an abnormal condition. Java handles them using try-catch-finally blocks. try encloses code

that may throw an exception.

Exception Types and Multiple Catch Clauses

Checked (compile-time) and Unchecked (runtime) exceptions. Multiple catch blocks handle different

exception types separately.

Nested Try, throw and throws

try blocks can be nested for more precise error handling. throw manually throws an exception. throws

declares exceptions a method can throw.

finally and Custom Exceptions

finally always executes, used for cleanup. Custom exceptions are created by extending Exception class.

Java Thread Model and Main Thread

Multithreading allows concurrent execution. The main thread starts automatically in a Java program.

Creating Threads and join()/isAlive()

Threads can be created by extending Thread or implementing Runnable. join() waits for a thread to finish.

isAlive() checks if a thread is active.

Thread Priorities and Synchronization

Thread priority affects scheduling. Synchronization prevents data inconsistency when multiple threads access

shared resources.
Java Programming - Exam Flashcards

Interthread Communication

Threads communicate using wait(), notify(), and notifyAll() methods. These are used to coordinate actions

among threads.

Java I/O and File Handling

The java.io package provides classes for file handling. Files are handled using FileInputStream,

FileOutputStream, FileReader, and FileWriter.

Stream Classes

Streams are used to read/write data. Byte streams handle raw binary data, while character streams handle

text.

The Applet Class and Lifecycle

Applets are small Java programs run in a browser or viewer. Lifecycle methods: init(), start(), paint(), stop(),

destroy().

Types of Applets and Architecture

Two types: local (via viewer) and remote (via browser). Applet architecture includes lifecycle methods and

interaction with the environment.

Simple Applet Display and Repainting

Display output using paint(). repaint() requests the applet to redraw itself.

Status Window and HTML APPLET Tag

Use showStatus() to show messages in the browser's status bar. The APPLET tag embeds applets in HTML.

Passing Parameters and Base Methods

Use <param> in HTML to pass parameters. getDocumentBase() returns page URL; getCodeBase() returns

applet class URL.

AppletContext and showDocument()

AppletContext allows communication between applets. showDocument() opens a webpage from the applet.

You might also like