Class 10 Notes On Encapsulation
Class 10 Notes On Encapsulation
Ans: The wrapping up to data and methods into a single unit(called class) is known as Encapsulation. For
example an engine of car or any vehicle contains many small parts, which enables the entire machinery system
to work. Encapsulation property hides the inner working of objects from the real world.
Ans: A class encapsulates Data Members that contains the information necessary to represent the class and
Ans: Visibility is a related term which refers to whether one can use a variable from a given place in the
program.
Ans: It is also called access specifier. It defines which function or method is able to use this method.
(a) PUBLIC: It means that any one can call this method.
(b) PRIVATE: It means that only the methods in the same class are permitted to use this method.
(c) PROTECTED: It means that methods in this class and methods in any subclass may access this method.
pg. 1
pg. 2
Define variable’s scope (scope rule)?
Ans: The program parts in which a particular data value (e.g., variable) can be accessed is known as variable’s
scope.
It can be accessed by any class, package. It can be accessed only by the member within class.
Private method and fields are not visible within Protected method and fields are visible
subclass. within subclass.
pg. 3
What is the default value of local variable?
The local variables are not initialised to any default value, neither primitives not object references.
Ans: The members that are declared static are called static members. These members are associate with the
Ans: Static variables are used when we want to have a variable common to all instances of a class.
Ans: A data member that is created for every objects of the class.
pg. 4
{
Ans: A java program contains many classes. But one class in a Java program contains the main() method. This
Ans: A data member that is declared once for a class. All objects of that class type, share these data members, as
there is single copy of them available in memory. Keyword ‘Static’ in the variable declaration makes a class
variable.
Ans: A data member that is created for every objects of the class.
pg. 5
Static method are used to be loaded in the memory without creating any object of that class in which method is
defined.
Ans: (i) Data declared at the class level can be used by all methods in the class.
(ii) Data declared within a method can be used only in the method.
(iv) Variable that are declared in block i.e., local variable are available to every method inside of the block.
(v) Variable declared in interior blocks are not available outside of that block.
(vi) Variable declared in exterior blocks are visible to the interior blocks.
Ans: Member variables are also known as Instance variables. These member variables are used to store value in
the class. It may be public, private and protected, where private and protected members remains hidden from
Ans: PRIVATE visibility of a Method means that only the methods in the same class are permitted to use this
method.
Answer : i) Yes, private member of a public class can be accessed by same class.
ii) No, other classes are unable to access private member of a public class.
iii) No, other package’s class can not access private member of a public class.
pg. 6
pg. 7