Unit summary
- A class defines fields, methods and constructors, and objects are created with new.
- Constructors initialise objects; this refers to the current object.
- Methods and constructors can be overloaded; static members belong to the class.
- Arrays hold fixed numbers of elements, in one or two dimensions, with length and bounds checking.
- String is immutable and StringBuffer mutable; Vector is a growable array; wrapper classes and enums complete the toolkit.
- Inheritance with extends reuses code; super reaches the superclass; overriding gives run-time polymorphism.
- Interfaces declare contracts, give multiple inheritance of type, and support polymorphism.
Glossary
| Term | Meaning |
|---|---|
| Abstract class | A class that cannot be instantiated. |
| Array | A fixed-size indexed collection of one type. |
| Autoboxing | Automatic primitive-to-wrapper conversion. |
| Class | A template defining fields and methods. |
| Constructor | A method that initialises a new object. |
| Dynamic dispatch | Choosing the method at run time. |
| Enum | A type with a fixed set of named constants. |
| Inheritance | Acquiring members of a superclass. |
| Interface | A contract of methods to implement. |
| Method overloading | Same name, different parameters. |
| Method overriding | Redefining an inherited method. |
| Object | An instance created from a class. |
| Static member | A member shared by the whole class. |
| String | An immutable sequence of characters. |
| StringBuffer | A mutable sequence of characters. |
| super | A reference to the superclass. |
| this | A reference to the current object. |
| Vector | A growable array of objects. |
| Wrapper class | A class wrapping a primitive value. |
Question bank
Short Answer Questions (2 marks each)
- Define a class and an object.
- What is a constructor?
- What is method overloading?
- What is a static method?
- How is an array created in Java?
- Why are strings immutable?
- What is a wrapper class?
- What is method overriding?
- What is the use of super?
- Define an interface.
Medium Answer Questions (5 marks each)
- Explain constructors with an example.
- Explain method overloading and static members.
- Explain one- and two-dimensional arrays with examples.
- Explain the String class and its methods.
- Explain the types of inheritance in Java.
- Explain interfaces and multiple inheritance.
Long Answer Questions (15 marks each)
- Explain classes, objects, methods, constructors and method overloading, with examples.
- Explain arrays, strings, vectors, wrapper classes and enumerated types.
- Explain inheritance, the super keyword and method overriding, with examples.
- Explain interfaces, multiple inheritance and polymorphism, and compare abstract classes with interfaces.
Sources
- Official BCA syllabus Object Oriented Programming using Java, course code 25BCA402SEC01, Unit III
