Java Interview Questions:
1. Features of JAVA ?
A. 1. Object Oriented: In Java, everything is an Object. Java Can be easily extended since it is
based on the Object model.
2.platform Independent
3.Simple: Java is designed to be easy to learn.
4.Secure: Java secure feature it enables to develop virus-free, tamper free system.
Authentication techniques are based on public-key encryption.
5.multithreaded: Java multithreaded feature it is possible to write programs that can perform
many tasks simultaneously.
6.High Performance: With the use of just-in-time compilers, java enables high performance.
7.Distributed: Java is des
For the distributed environment of the internet.
2. Differences between JDK, JRE and JVM.
JDK: Java Development Kit is a software development environment used for developing Java
applications and applets. It includes the Java Runtime ENVIRONMENT(JRE) an interpreter/loader
a complier an archiver a documentation generator and other tools needed in java development.
JRE: Java Runtime Environment is an installation package that provides an environment to only
run the java program onto your machine. JRE is only used by those who only want to run java
program that end-users of your system.
JVM: Java Virtual Machine is very important part of both JDK and JRE because it is contained or
inbuilt in both.
3. Explain JAVA memory model?
The Java Virtual Machine defines various run-time data areas that are used during execution of
a program.
Some of these data areas are created on JVM start-up and are destroyed only when the JVM
exits. Other data areas are created and exist one per thread. Per-thread data areas are created
when a thread is created and destroyed when the thread exit.
1.Heap memory: The heap area represents the runtime data area, from which the memory is
allocated for all class instances and arrays and is created during the virtual machine startup.
2. Method area and runtime constant pool: Method area stores per-class structures such as the
runtime constant pool; field and method data; the code for methods and constructors, including
the special methods used in class, instance, and interface initialization
3. Stacks:
Each of the JVM threads has a private stack created at the same time as that of the thread. The
stack stores frames. A frame is used to store data and partial results and to perform dynamic
linking, return values for methods, and dispatch exceptions.
4. Native method stacks:
Native method stacks are called C stacks; they support native methods (methods are written in
a language other than the Java programming language), typically allocated per each thread
when each thread is created. Java Virtual Machine implementations that cannot load native
methods and that do not themselves rely on conventional stacks need not supply native
method stacks.
5. PC registers:
Each of the JVM threads has its own program counter (pc) register. At any point, each of the
JVM threads is executing the code of a single method, namely the current method for that
executing thread.
4. Different types of variables in JAVA ?
There are three different types of variables a class can have in Java are local
variables, instance variables, and class/static variables.
Local Variable
A local variable in Java can be declared locally in methods, code blocks, and constructors.
When the program control enters the methods, code blocks, and constructors then the local
variables are created and when the program control leaves the methods, code blocks, and
constructors then the local variables are destroyed. A local variable must be initialized with
some value.
Instance Variable
An instance variable in Java can be declared outside a block, method or constructor but inside
a class. These variables are created when the class object is created and destroyed when the
class object is destroyed.
Static/Class Variable
A static/class variable can be defined using the static keyword. These variables are
declared inside a class but outside a method and code block. A class/static variable can
be created at the start of the program and destroyed at the end of the program.
5. What is Class and Object ?
Class: Class is used as a template for declaring and creating the objects. When a class is created,
no memory is allocated. The class must be declared first and only once. A class is a logical entity.
It is declared with the class keyword.
Object: An object is an instance of a class. Objects are allocated memory space whenever they
are created. An object is created many times as per requirement. An object is a physical entity.
Objects can be manipulated. It is created with a class name in C++ and with the new keywords
in Java.
6. What are different OOPS concepts?
1. Class
2. Object
3. Method and method passing
4. Pillars of OOPs
Abstraction
Encapsulation
Inheritance
Polymorphism
Compile-time polymorphism
Runtime polymorphism
7. What is Abstraction?
In Java, abstraction is achieved by interfaces and abstract classes. We can achieve 100%
abstraction using interfaces.
Data Abstraction may also be defined as the process of identifying only the required
characteristics of an object ignoring the irrelevant details. The properties and behaviors of an
object differentiate it from other objects of similar type and also help in classifying/grouping the
objects.
An abstract class is a class that is declared with an abstract keyword.
An abstract method is a method that is declared without implementation.
An abstract class may or may not have all abstract methods. Some of them can be concrete
methods
A method-defined abstract must always be redefined in the subclass, thus
making overriding compulsory or making the subclass itself abstract.
Any class that contains one or more abstract methods must also be declared with an abstract
keyword.
There can be no object of an abstract class. That is, an abstract class can not be directly
instantiated with the new operator.
An abstract class can have parameterized constructors and the default constructor is always
present in an abstract class
8. What is Encapsulation?
Encapsulation is a fundamental concept in object-oriented programming (OOP) that refers to
the bundling of data and methods that operate on that data within a single unit, which is called
a class in Java. Encapsulation is a way of hiding the implementation details of a class from
outside access and only exposing a public interface that can be used to interact with the class.
In Java, encapsulation is achieved by declaring the instance variables of a class as private, which
means they can only be accessed within the class. To allow outside access to the instance
variables, public methods called getters and setters are defined, which are used to retrieve and
modify the values of the instance variables, respectively. By using getters and setters, the class
can enforce its own data validation rules and ensure that its internal state remains consistent.
9. What is the difference between abstraction and encapsulation?
Abstracti
Encapsulation
on
It is the process of gaining It is a method that helps wrap up
1.
information. data into a single module.
2. The problems in this technique Problems in encapsulation are
are solved at the interface level. solved at the implementation level.
It helps hide the unwanted It helps hide data using a single
details/information. entity, or using a unit with the help
3.
of method that helps protect the
information.
It can be implemented using It can be implemented using access
4. abstract classes and interfaces. modifiers like public, private and
protected.
The complexities of the The data is hidden using methods
5. implementation are hidden using such as getters and setters.
interface and abstract class.
Abstraction can be performed Objects in encapsulation don't need
using objects that are to be in abstraction.
6.
encapsulated within a single
module.
10. What is Inheritance?
It is the mechanism in Java by which one class is allowed to inherit the features(fields and
methods) of another class. In Java, Inheritance means creating new classes based on existing
ones. A class that inherits from another class can reuse the methods and fields of that class. In
addition, you can add new fields and methods to your current class as well.
Important Terminologies Used in Java Inheritance
Class: Class is a set of objects which shares common characteristics/ behavior and common
properties/ attributes. Class is not a real-world entity. It is just a template or blueprint or
prototype from which objects are created.
Super Class/Parent Class: The class whose features are inherited is known as a superclass(or a
base class or a parent class).
Sub Class/Child Class: The class that inherits the other class is known as a subclass(or a derived
class, extended class, or child class). The subclass can add its own fields and methods in addition
to the superclass fields and methods.
Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a
new class and there is already a class that includes some of the code that we want, we can
derive our new class from the existing class. By doing this, we are reusing the fields and
methods of the existing class.
11. What is Polymorphism?& What is method overloading and method overriding ?
Polymorphism means many forms
2 types:
1.Compile time polymorphism/method overloading: same method name with different number
of arguments. Same method name with same number of arguments but different data types.
Void add();
Void add(int a, int b);
Void add(int a, int b, int c);
Void add(float a , float b);
2.Runtime polymorphism/method overriding:
Same method name with same number of arguments in super class and sub class
Whenever we are having same method name with same number of arguments in super class
and sub class by default sub class method will be executed.
If we want to execute super class method also, we need to call superclass method in subclass
method is using keywords.
13. What is static in JAVA ?
The static keyword in Java is mainly used for memory management. The static keyword in Java is
used to share the same variable or method of a given class. The users can apply static keywords
with variables, methods, blocks, and nested classes. The static keyword belongs to the class
than an instance of the class. The static keyword is used for a constant variable or a method that
is the same for every instance of a class.
The static keyword is a non-access modifier in Java that is applicable for the following:
Blocks
Variables
Methods
Classes
14. What is final, finally, finalize ?
Final:
An access modifier used with variables, methods, and classes to set access permissions.
Finally:
An exception handling block used to ensure that a section of code is always executed, even if an
exception is thrown.
Finalize:
An object class function used to perform cleanup processing on an object before it is garbage
collected.
15. What is static and dynamic binding ?
Connecting a method call to the method body is known as binding.
There are two types of binding
1.Static Binding (also known as Early Binding): When type of the object is determined at
compiled time (by the compiler), it is known as static binding.
If there is any private, final or static method in a class, there is static binding.
2.Dynamic Binding (also known as Late Binding): When type of the object is determined at run-
time, it is known as dynamic binding.
16. Abstarct vs inerface ?
Abstract Class: An abstract class is a class that cannot be instantiated on its own; instead, it's
meant to be subclassed by other classes. It serves as a blueprint for creating derived
(sub)classes. Abstract classes can have both regular methods (with or without implementation)
and abstract methods (methods without implementation, only declaring method signature).
Subclasses that extend an abstract class must provide implementations for all the abstract
methods declared in the abstract class. Abstract classes can also have instance variables,
constructors, and non-abstract methods with actual implementations.
Interface: An interface is a contract that defines a set of methods that a class must implement.
It's a way to achieve multiple inheritances in languages that don't support multiple inheritance
directly. An interface only provides method signatures; it doesn't contain any method
implementations or instance variables. A class can implement multiple interfaces, and when it
does, it must provide implementations for all the methods defined in those interfaces.
Key Differences:
Instantiation: Abstract classes cannot be instantiated directly, while interfaces cannot be
instantiated at all. They both need to be implemented/extended by concrete classes.
Method Implementation: Abstract classes can have both implemented and abstract methods.
Interfaces can only declare method signatures; they don't include any implementations.
Multiple Inheritance: A class can implement multiple interfaces, but it can only directly inherit
from one abstract class.
Fields and Constructors: Abstract classes can have instance variables and constructors, while
interfaces cannot have either.
Method Accessibility: In an interface, all methods are implicitly public. In an abstract class,
methods can have different access modifiers.
Usage: Abstract classes are used when you want to provide a common base with some shared
functionality among multiple related classes. Interfaces are used to ensure that classes adhere
to a certain contract, allowing classes to implement multiple contracts.
17. Which one you choose between abstract and interface ?
Interfaces and abstract classes provide similar functionality, so it is important to know when to
select one over the other as you design a system. In general, you should choose interfaces over
abstract classes. The use of an interface separates your design from any implementation details.
Choose an Abstract Class When:
Common Implementation: You want to provide a common base with shared implementation
among related classes. Abstract classes can have both implemented methods and abstract
methods, allowing you to share code among subclasses.
Partial Implementation: Some methods can be fully implemented in the abstract class and
reused by subclasses, while other methods are left abstract to be implemented by subclasses.
Base with State: You need to define instance variables (state) that can be shared among
subclasses.
Changeable Implementation: You anticipate that the implementation of some methods might
change over time, and you want to provide a central point to modify that implementation for all
subclasses.
Choose an Interface When:
Multiple Contracts: You want to ensure that multiple classes adhere to a common set of method
signatures without providing any implementation details.
Multiple Inheritance: You need to achieve multiple inheritance-like behavior since a class can
implement multiple interfaces but can only extend one class.
Unrelated Classes: The classes implementing the interface are not necessarily related in terms
of behavior or hierarchy.
Future Compatibility: You want to design for flexibility, allowing different classes to implement
the interface even if they don't share a common base class.
18. Why do create abstract classes in application development ?
Abstract classes are created in application development for several reasons, primarily to provide
a common base for related classes that share certain behavior, properties, or methods. Here are
some key reasons why abstract classes are used:
Code Reusability: Abstract classes allow you to define common methods and behavior once in
the abstract class and have them inherited by its subclasses. This promotes code reusability and
reduces the need to duplicate code across multiple classes.
Common Interface: Abstract classes provide a way to define a common interface for a group of
related classes. This helps ensure that all subclasses adhere to a certain structure and set of
methods, creating a consistent and predictable codebase.
Partial Implementation: Abstract classes can have both implemented methods and abstract
methods. This is useful when you want to provide a default implementation for certain methods
that can be reused by subclasses, while still forcing subclasses to provide their own
implementations for specific methods.
Enforcing Method Contracts: By using abstract methods, you can enforce that subclasses
provide implementations for specific methods. This helps ensure that essential behavior is
implemented in all subclasses.
Framework Design: In software frameworks, abstract classes are often used to define the
foundation for the framework's components. Subclasses then build upon this foundation to
create specialized components.
Polymorphism: Abstract classes enable polymorphism, which allows you to treat different
subclasses as instances of a common superclass. This simplifies code and allows for dynamic
behavior based on the actual subclass being used.
Centralized Changes: If there are changes or improvements that need to be made to the shared
behavior, you can make those changes in the abstract class, and they will automatically affect all
the subclasses. This helps centralize maintenance and updates.
Hierarchy and Inheritance: Abstract classes contribute to the hierarchy of classes by serving as
intermediate layers between base classes and more specific subclasses. This can help in
organizing your code and representing relationships between different classes.
Combining Behavior: If you have multiple aspects of behavior that you want to mix and match
across classes, an abstract class can combine these aspects into a single structure.
Method Hooking: Abstract classes can provide "hook" methods, which are methods that are
declared in the abstract class but meant to be overridden by subclasses. This allows subclasses
to influence or extend the behavior of the abstract class.
19. why do create interfaces in application development?
Interfaces are created in application development for several important reasons, as they provide
a way to define contracts, enforce behavior, and enable flexible design patterns.
20. What are different types of access modifiers?
Access modifiers are keywords in object-oriented programming languages that define the
visibility and accessibility of class members (fields, methods, etc.) within different parts of the
codebase. Different programming languages might have slightly different names or variations
for these modifiers, but they generally serve similar purposes. Here are the common types of
access modifiers:
Public: Members declared as public are accessible from anywhere in the codebase, both within
the defining class and from any other class that has access to the instance of that class.
Private: Private members are only accessible within the class where they are defined. They
cannot be accessed from outside the class, even from subclasses.
Protected: Protected members are accessible within the class where they are defined and in
subclasses. However, they are not accessible from outside the class hierarchy.
Default (Package-private): Also known as "package-private" or "friendly" in some languages,
members with no explicit access modifier are accessible within the same package (or
namespace) but not outside of it.
21. What is call by value?
"Call by value" is a parameter passing mechanism used in programming languages when
invoking functions or methods. In this mechanism, a copy of the actual argument's value is
passed to the function as a parameter. This means that any changes made to the parameter
inside the function do not affect the original value of the argument outside the function.
22. What is String pool?
A string pool, also known as a string constant pool or string intern pool, is a memory
optimization technique used in programming languages to store and manage strings. The
purpose of a string pool is to ensure that only one copy of each unique string value is stored in
memory, thereby saving memory and improving efficiency.
In languages that implement a string pool, such as Java, the concept works as follows:
String Creation: Whenever you create a string literal (a sequence of characters enclosed in
double quotes) in your code, the programming language checks if that exact string value already
exists in the pool.
Pooling: If the string value already exists in the pool, the reference to the existing string is
returned, and a new object is not created. This means that multiple variables can refer to the
same string instance.
Memory Efficiency: Since only one copy of each unique string is stored in memory, the overall
memory consumption is reduced, especially in cases where the same string is used multiple
times in the program.
String Immutability: The string pool works particularly well with immutable strings (strings that
cannot be changed after they are created), as there is no risk of unintended changes affecting
other parts of the code.
String s1 = "Hello"; // Creates a string "Hello" in the pool
String s2 = "Hello"; // Reuses the existing string "Hello" from the pool
String s3 = new String("Hello"); // Creates a new string object, not in the pool
System.out.println(s1 == s2); // true, as both refer to the same pooled instance
System.out.println(s1 == s3); // false, as s3 points to a new instance
Certainly, I'll provide you with more detailed answers that are suitable for interview scenarios:
23. Why is String immutable?
Strings are immutable to prevent accidental changes to their content. This ensures that once a
string is created, its value remains consistent throughout the program's execution. Immutability
also enables string interning, which saves memory and optimizes performance.
24. How do you make a class immutable?
To create an immutable class:
- Declare the class as `final` to prevent inheritance.
- Declare all fields as `private` and `final`.
- Provide only getters for fields; avoid setters.
- Ensure that mutable objects (if any) within the class are defensively copied during
construction.
25. StringBuilder vs String Buffer?
Both `StringBuilder` and `String Buffer` are used for string manipulation, but `StringBuilder` is
recommended in single-threaded environments due to its better performance. Use `String
Buffer` in multi-threaded scenarios where thread safety is essential.
26. == vs equals?
`==` compares object references, while `equals` compares the content. Use `==` to check
reference equality and `equals` for content equality.
27. What is Exception Handling and How do you achieve it?
Exception handling is the practice of dealing with runtime errors gracefully to prevent program
crashes. It's achieved using `try`, `catch`, and `finally` blocks. Use `try` to enclose code that
might throw exceptions, `catch` to handle exceptions, and `finally` to ensure cleanup code is
executed regardless of exceptions.
28. How do you make sure code must be executed even if an exception happens?
To ensure code execution even after an exception, place the critical code in the `finally` block.
The code within the `finally` block is executed regardless of whether an exception occurred or
not.
29. What code do you normally write in the finally block?
The `finally` block is suitable for releasing resources like closing files, database connections, or
network sockets. It's used for cleanup tasks that must be performed regardless of exceptions.
30. Checked vs Unchecked exceptions?
Checked exceptions are compile-time checked and must be either caught using `try-catch` or
declared with `throws`. Unchecked exceptions are typically programming errors and extend
`RuntimeException`. They don't require explicit handling.
31. How do you create a custom Exception?
To create a custom exception, define a class that extends the `Exception` class or its
subclasses. Provide constructors to initialize exception messages or additional information.
32. How does exception propagation work?
Exception propagation is the process of passing an exception up the call stack. When an
exception is thrown in a method, the runtime searches for a matching `catch` block in the calling
methods. If not found, the exception propagates further up the call stack.
33. throw vs throws?
`throw` is used to throw an exception explicitly within a method. `throws` is used in method
declarations to indicate that the method may throw certain exceptions that need to be handled.
34. Exception vs Error?
Exceptions are recoverable issues in the application logic, while errors represent serious issues
that often cannot be recovered from. Errors typically indicate problems outside the application's
control.
35. What are inner classes?
Inner classes are classes defined within another class. They allow you to encapsulate and
group related classes together, improving code organization and readability.
36. What is an Anonymous class?
An anonymous class is a class defined without a name. It's often used for implementing
interfaces or extending classes inline, especially for one-time use.
Here's the continuation of the detailed answers:
37. Java Collection Framework tree?
The Java Collection Framework includes interfaces (List, Set, Queue, Map) and classes like
ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap. These classes provide various data
structures and algorithms for handling collections of objects.
38. ArrayList vs LinkedList?
`ArrayList` uses a dynamic array to store elements, providing efficient random access.
`LinkedList` uses a doubly linked list, which is better for frequent insertions and deletions.
Choose `ArrayList` for scenarios where retrieval is more common, and `LinkedList` for frequent
modification.
39. ArrayList vs Set?
`ArrayList` is a dynamic array that allows duplicates. `Set` is an interface that defines
collections with no duplicates and no specific order. Use `ArrayList` when order and duplicates
matter; use `Set` for unique elements.
40. Which one do you prefer between ArrayList vs LinkedList?
It depends on the specific use case. If you need efficient random access and iteration, choose
`ArrayList`. For frequent insertions and deletions, especially in the middle of the list, consider
`LinkedList`.
41. How do you sort a collection of elements in JAVA?
Use the `Collections.sort()` method for sorting lists. Implement the `Comparable` interface in
the class you're sorting, and override the `compareTo()` method to define the sorting criteria.
Alternatively, use the `Comparator` interface to provide custom sorting logic.
42. What is Collections class in JAVA?
The `Collections` class in Java provides utility methods for common operations on collections.
It includes methods for sorting, searching, reversing, shuffling, and synchronizing collections.
43. Hashtable vs HashMap?
Both `Hashtable` and `HashMap` store key-value pairs, but `Hashtable` is synchronized and
thread-safe, while `HashMap` is not. Use `HashMap` unless you specifically need thread-safe
behavior.
44. What is HashMap?
`HashMap` is a data structure that implements the `Map` interface, allowing you to store key-
value pairs. It provides fast retrieval of values based on keys and is commonly used for efficient
data lookups.
45. How does HashMap Work?
`HashMap` uses the hash code of keys to determine the bucket where the corresponding
value is stored. Collisions are resolved using linked lists (or trees in Java 8+) within buckets.
46. What is HashMap Collision?
HashMap collision occurs when two different keys produce the same hash code, causing them
to be stored in the same bucket. Collisions are resolved using a linked list or tree structure.
47. What is Concurrent HashMap?
`Concurrent HashMap` is a thread-safe version of `HashMap` designed for multi-threaded
environments. It achieves thread safety by dividing the map into segments, reducing contention
for locks.
48. Why do you think Strings make appropriate keys for HashMap?
Strings are commonly used as keys because of their immutability, well-defined `hashCode()`
and `equals()` methods, and widespread use. These properties ensure consistent and efficient
hashing and retrieval.
49. What kind of classes are good for HashMap keys?
Classes with proper `hashCode()` and `equals()` implementations are suitable for HashMap
keys. These methods ensure correct retrieval and comparison of keys.
50. Iterator vs ListIterator?
`Iterator` is used to traverse elements in a collection in a forward direction. `ListIterator`
extends `Iterator` and is specific to lists, allowing bidirectional traversal and element
modification.
51. Comparable vs Comparator interfaces?
`Comparable` is used for natural ordering and is implemented by the object being compared.
`Comparator` is used for custom ordering and is an external class that provides comparison
logic.
52. TreeSet and TreeMap?
`TreeSet` is a sorted set implemented using a self-balancing binary search tree. `TreeMap` is a
sorted map that uses the same structure for key-value pairs.
53. What is the contract between hashCode and equals?
The contract states that if two objects are equal according to the `equals()` method, their hash
codes must be equal. However, the reverse is not necessarily true.
54. Why do you need to override hashCode and equals?
Overriding `hashCode()` and `equals()` is essential to ensure that objects behave correctly in
hash-based data structures like `HashMap` and `HashSet`.
55. What is multi-threading?
Multithreading is the concurrent execution of multiple threads in a single process. It allows
programs to perform tasks concurrently, utilizing multiple CPUs or CPU cores.
56.How do you create Threads?
Threads can be created by implementing the `Runnable` interface and passing it to a `Thread`
constructor. Alternatively, you can extend the `Thread` class and override its `run()` method.
57. How do you synchronize your code?
Synchronize critical sections of code using the `synchronized` keyword. This ensures that only
one thread can execute the synchronized block or method at a time.
58. What is volatile?
The `volatile` keyword ensures that a variable is accessed directly from memory and not
cached locally by threads. It's used to guarantee visibility of changes across threads.
59. What is a race condition?
A race condition occurs when multiple threads access shared resources concurrently, leading
to unpredictable and unintended behavior due to the order of execution.
60. What is a deadlock?
A deadlock occurs when two or more threads are unable to proceed because each is waiting
for a resource held by the other, resulting in a deadlock situation.
61. What is ThreadLocal?
`ThreadLocal` allows each thread to have its own independent copy of a variable. It's used to
avoid sharing data between threads and minimize synchronization.
62. What is ThreadPool?
A ThreadPool is a pool of pre-created threads that can be used to execute tasks concurrently.
It reduces the overhead of creating and destroying threads for every task, improving efficiency.
63. How do you use the Executor framework?
The Executor framework provides a higher-level interface for managing and executing tasks
using thread pools. You can use implementations like `ExecutorService` and
`ThreadPoolExecutor` to submit and manage tasks.
64. What is starvation?
Starvation occurs when a thread is unable to access a shared resource or obtain CPU time due
to higher-priority threads monopolizing those resources. This can lead to the affected thread
not making progress.
65. Synchronized methods vs Synchronized blocks?
Synchronized methods lock the entire method, preventing simultaneous execution by multiple
threads. Synchronized blocks allow more fine-grained control by locking specific sections of
code, reducing contention and improving performance.
66. What is serialization and externalization?
Serialization is the process of converting an object's state into a byte stream for storage or
transmission. Externalization is a mechanism that allows you to customize the serialization
process by implementing the `Externalizable` interface.
67.How do you avoid a variable participating in serialization?
Mark the variable as `transient`. Transient variables are not serialized, ensuring that sensitive
or unnecessary data is not persisted.
68. What is a marker interface?
A marker interface is an interface with no methods, used to provide metadata or enable
specific behavior in classes implementing it. Examples include `Serializable`, `Cloneable`, and
`RandomAccess`.
69. What is Enum in JAVA?
An `enum` is a special data type in Java that represents a fixed set of constants. Enumerations
provide type safety, readability, and a well-defined set of values, often used to represent a
collection of related values or options.