Computer Science, asked by saliksahu5star, 7 months ago

A class defined within another class is
एक अन्य क्लास के भीतर परिभाषित क्लास है
Select one:
:
a. Inheritance
इनहेरिटेंस
. b.Nested class
नेस्टेड क्लास
c. Encapsulation
एनकैप्सूलेशन
d. Containership
कंटेनरशिप​

Answers

Answered by keyboardavro
2

Answer:

Nested classes

Explanation:

The Java programming language allows you to define a class within another class. Such a class is called a nested class and is illustrated here: ... Nested classes that are declared static are called static nested classes. Non-static nested classes are called inner classes.

Answered by Sreejanandakumarsl
0

Answer:

The correct answer is (b)Nested Class.

Therefore, a class defined within another class is a nested class.

Explanation:

  • A nested class is a component of the parent class.
  • Even though they are private, non-static nested classes (inner classes) can access other members of the surrounding class.
  • No other members of the enclosing class are accessible to static nested classes.
  • A nested class can be declared private, public, protected, or package private as a member of the OuterClass.

The following are compelling justifications for using nested classes:

  1. It is a method of rationally combining classes that are only used once. If a class is only beneficial to one other class, it makes sense to keep the two of them together. Such "helper classes" can be nested to make their package more efficient.
  2. Lets now Consider two top-level classes, A and B, where B needs access to members of A that would otherwise be designated as private. This promotes encapsulation. Class A's members can be set as private and made accessible to class B by enclosing class B within class A. B itself can also be kept a secret from the outer world.
  3. It may produce code that is easier to read and maintain: The code is moved closer to its intended purpose by nesting minor classes into top-level classes.

#SPJ6

Similar questions