PDF Notes: UNIT-2

    Master this deck with 13 terms through effective study methods.

    Generated from uploaded pdf

    Created by @yadav

    What is method overloading?

    Allows multiple methods with the same name but different signatures.

    How does method overloading increase program readability?

    By allowing similar methods to be used with different parameters.

    What are the three ways to overload a method?

    Change number, data type, or sequence of parameters.

    What is a key rule for method overloading?

    Method signature must differ; return type alone is not sufficient.

    What happens if you change only the return type in method overloading?

    It causes ambiguity and results in a compilation error.

    What is type promotion in method overloading?

    Smaller data types are automatically converted to larger types.

    What distinguishes pass-by-value from pass-by-reference?

    Pass-by-value copies the value, while pass-by-reference shares the object reference.

    What is the implication of passing an object as a parameter?

    Modifications affect the actual object since the reference is shared.

    What can a method in Java return?

    Any data type, including objects.

    What is an inner class?

    A class defined within another class, allowing access to outer class members.

    What are the advantages of inner classes?

    They provide name control, access control, and improve code readability.

    How do you instantiate an inner class from outside the outer class?

    You need an instance of the outer class to create the inner class instance.

    What are the types of nested classes?

    Member inner class, anonymous inner class, local inner class, and static nested class.