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)

  1. Define a class and an object.
  2. What is a constructor?
  3. What is method overloading?
  4. What is a static method?
  5. How is an array created in Java?
  6. Why are strings immutable?
  7. What is a wrapper class?
  8. What is method overriding?
  9. What is the use of super?
  10. Define an interface.

Medium Answer Questions (5 marks each)

  1. Explain constructors with an example.
  2. Explain method overloading and static members.
  3. Explain one- and two-dimensional arrays with examples.
  4. Explain the String class and its methods.
  5. Explain the types of inheritance in Java.
  6. Explain interfaces and multiple inheritance.

Long Answer Questions (15 marks each)

  1. Explain classes, objects, methods, constructors and method overloading, with examples.
  2. Explain arrays, strings, vectors, wrapper classes and enumerated types.
  3. Explain inheritance, the super keyword and method overriding, with examples.
  4. 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