You are on page 1of 1

MUHAMMAD NAEEMUDDIN OOP-LAB-4 CMS# 1955-2021

4.1

Both variable and method are publicly accessible as the keyword public is used prior to the names. They
both did not contain any assignments yet. More precisely, they did not have any values or operations
which they could perform upon calling.

4.2

ACCESS MODIFIERS NON-ACCESS MODIFIERS


• To control the accessibility of the fields • Non-access modifiers provide special
and method of a class, we use access functionality to the code when called to
modifiers. the class.
• Certain types of access modifiers • Certain non-access modifiers are
• are specified by C#. specified by C#.
• Public: Keyword followed by the class • Static: Used to make variable and
name or method indicates that this methods accessible without instance of
class is accessible in any part of the the class.
code • Abstract: Used to make a class which
• Private: Keyword followed by the class cannot be instantiated.
name or method indicates that this part
of the code is accessible within the
scope of the same class.
• Protected: Keyword followed by the
class name or method indicates that
this part of code is accessible in the
same class and the classes derived from
that class.

4.3

The subclasses cannot be created as we have modified the access of the field and methods of the parent
class.

You might also like