What is an interface in Java?
A collection of abstract methods and constants that establishes a set of methods that a class must implement
What are the key differences between interfaces and classes?
What is an Abstract Data Type (ADT)?
A collection of data items together with the operations that can be performed on that data, specifying WHAT operations do but not HOW they do it
When should you use interfaces in Java?
What is abstraction in programming?
The separation of purpose (what something does) from implementation (how it does it), allowing users to use functionality without knowing internal details
What are generics in Java?
A feature that allows classes, interfaces, and methods to be written as templates that can work with any data type while maintaining type safety at compile time
Why can’t primitive types be used directly with generics?
Primitive types cannot be used directly in angle brackets (like ). Instead, wrapper classes must be used (like )
How do you make a class generic?
Add a type parameter in angle brackets after the class name (e.g., class Name) and use that parameter as a type within the class
What is a data structure?
A particular way of organizing data in a computer so that it can be used efficiently, with different structures suited to different applications
What are the key characteristics of an algorithm?
What is a linked structure?
A collection of objects (nodes) storing data and links to other objects, where each node contains both data and references to other nodes
What are the advantages of arrays?
What are the disadvantages of arrays?
What is the difference between == and .equals() for objects?
== compares if two references point to the same object in memory, while .equals() compares the actual content/values of the objects
What is a node in the context of linked structures?
An object in a linked structure that contains both data and references (links) to other nodes of the same type
What happens if you lose the first reference in a linked structure?
You lose access to the entire chain of nodes since there’s no way to reach them without the first reference
What are wrapper classes used for in Java?
To convert primitive data types into objects, allowing them to be used with generics and collections (e.g., Integer for int, Double for double)
What is the purpose of type parameters in generic classes?
To allow the class to work with different data types while maintaining type safety, using placeholders like or that are replaced with actual types when used
What is a Stack and what principle does it follow?
A Stack is a collection whose elements are added and removed from the same end (top). It follows LIFO (Last In, First Out) principle
What are the primary operations of a Stack ADT?
What is a Queue and what principle does it follow?
A Queue is a collection where elements are added at rear and removed from front. It follows FIFO (First In, First Out) principle
What are the primary operations of a Queue ADT?
What are the differences between array and linked implementations of a Stack?
Array implementation: Push O(n)* due to resizing, Pop O(1). Linked implementation: Both Push and Pop are O(1), but uses more memory for links
What are the key differences between ArrayQueue and LinkedQueue?
ArrayQueue: enqueue/dequeue O(n) due to shifting. LinkedQueue: both operations O(1). Array implementation uses less memory but has fixed size initially