SlideShare a Scribd company logo
1 of 3
Download to read offline
Access Modifiers: To set the access levels of variables,methods (members of a class) we use
Access Modifiers.The different types of access specifiers available are:
1. Public
2. Private
3. Protected
Public: When we declare a variable, method as public, it means that we can access those from
outside the class but within a program . When we inherit a class all public members of the class
will be accessible by the derived class.
Usage: Prefix the variable or method definition by the keyword public.
Example: public:
int x;
public:
void print();
Private: When we declare a variable, method as private, it means that we can access them only
within the class. Private variables of a class can be accessed only through getter and setter
methods which are public. By default the members of a class are private, if we do not specify any
access modifier it is considered to be private. This is concept used to achieve encapsulation.
Usage: Prefix the variable or method definition by the keyword private
Example: private:
int x;
public:
void setX();
Protected: When we declare a class, variable, method.,etc as public, it means that we can access
them within the class and the class with inherits it i.e,protected members can be accessed by the
derived class or child class also.
Usage: Prefix the variable or method definition by the keyword protected
Example: protected:
int x;
1(c): class Rectangle: public Shape{
protected:
string _type;
public:
bool isSquare() {
if(width==height) return true;
return false;
}
double area() {
return width*height;
}
};
How are the Rectangle class and Shape class related?
Answer: D. The Rectangle class inherits the Shape class.
Solution
Access Modifiers: To set the access levels of variables,methods (members of a class) we use
Access Modifiers.The different types of access specifiers available are:
1. Public
2. Private
3. Protected
Public: When we declare a variable, method as public, it means that we can access those from
outside the class but within a program . When we inherit a class all public members of the class
will be accessible by the derived class.
Usage: Prefix the variable or method definition by the keyword public.
Example: public:
int x;
public:
void print();
Private: When we declare a variable, method as private, it means that we can access them only
within the class. Private variables of a class can be accessed only through getter and setter
methods which are public. By default the members of a class are private, if we do not specify any
access modifier it is considered to be private. This is concept used to achieve encapsulation.
Usage: Prefix the variable or method definition by the keyword private
Example: private:
int x;
public:
void setX();
Protected: When we declare a class, variable, method.,etc as public, it means that we can access
them within the class and the class with inherits it i.e,protected members can be accessed by the
derived class or child class also.
Usage: Prefix the variable or method definition by the keyword protected
Example: protected:
int x;
1(c): class Rectangle: public Shape{
protected:
string _type;
public:
bool isSquare() {
if(width==height) return true;
return false;
}
double area() {
return width*height;
}
};
How are the Rectangle class and Shape class related?
Answer: D. The Rectangle class inherits the Shape class.

More Related Content

Similar to Access Modifiers To set the access levels of variables,methods (mem.pdf

Chapter18 class-and-objects
Chapter18 class-and-objectsChapter18 class-and-objects
Chapter18 class-and-objectsDeepak Singh
 
access modifier
access modifieraccess modifier
access modifiercpsivaku
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesVinay Kumar
 
Master of Computer Application (MCA) – Semester 4 MC0078
Master of Computer Application (MCA) – Semester 4  MC0078Master of Computer Application (MCA) – Semester 4  MC0078
Master of Computer Application (MCA) – Semester 4 MC0078Aravind NC
 
Access Protection
Access ProtectionAccess Protection
Access Protectionmyrajendra
 
Power point presentation on access specifier in OOPs
Power point presentation on access specifier in OOPsPower point presentation on access specifier in OOPs
Power point presentation on access specifier in OOPsAdrizaBera
 
Inheritance in c++ part1
Inheritance in c++ part1Inheritance in c++ part1
Inheritance in c++ part1Mirza Hussain
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++RAJ KUMAR
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview QestionsArun Vasanth
 
Chapter 03 enscapsulation
Chapter 03 enscapsulationChapter 03 enscapsulation
Chapter 03 enscapsulationNurhanna Aziz
 
Access modifiers
Access modifiersAccess modifiers
Access modifiersJadavsejal
 
Visibility Modifiers for Access Control.pptx
Visibility Modifiers for Access Control.pptxVisibility Modifiers for Access Control.pptx
Visibility Modifiers for Access Control.pptxnaazminshaikh1727
 
116824015 java-j2 ee
116824015 java-j2 ee116824015 java-j2 ee
116824015 java-j2 eehomeworkping9
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In JavaMD SALEEM QAISAR
 

Similar to Access Modifiers To set the access levels of variables,methods (mem.pdf (20)

Chapter18 class-and-objects
Chapter18 class-and-objectsChapter18 class-and-objects
Chapter18 class-and-objects
 
access modifier
access modifieraccess modifier
access modifier
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
Java presentation
Java presentationJava presentation
Java presentation
 
Master of Computer Application (MCA) – Semester 4 MC0078
Master of Computer Application (MCA) – Semester 4  MC0078Master of Computer Application (MCA) – Semester 4  MC0078
Master of Computer Application (MCA) – Semester 4 MC0078
 
Access Protection
Access ProtectionAccess Protection
Access Protection
 
Power point presentation on access specifier in OOPs
Power point presentation on access specifier in OOPsPower point presentation on access specifier in OOPs
Power point presentation on access specifier in OOPs
 
Inheritance in c++ part1
Inheritance in c++ part1Inheritance in c++ part1
Inheritance in c++ part1
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Assigment 2
Assigment 2Assigment 2
Assigment 2
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Java/J2EE interview Qestions
Java/J2EE interview QestionsJava/J2EE interview Qestions
Java/J2EE interview Qestions
 
00ps inheritace using c++
00ps inheritace using c++00ps inheritace using c++
00ps inheritace using c++
 
Chapter 03 enscapsulation
Chapter 03 enscapsulationChapter 03 enscapsulation
Chapter 03 enscapsulation
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Visibility Modifiers for Access Control.pptx
Visibility Modifiers for Access Control.pptxVisibility Modifiers for Access Control.pptx
Visibility Modifiers for Access Control.pptx
 
116824015 java-j2 ee
116824015 java-j2 ee116824015 java-j2 ee
116824015 java-j2 ee
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In Java
 

More from sanjeevtandonsre

Above 70 °C, sodium bicarbonate gradually decomposes into sodium car.pdf
  Above 70 °C, sodium bicarbonate gradually decomposes into sodium car.pdf  Above 70 °C, sodium bicarbonate gradually decomposes into sodium car.pdf
Above 70 °C, sodium bicarbonate gradually decomposes into sodium car.pdfsanjeevtandonsre
 
You need to put your electrons in the first one .pdf
                     You need to put your electrons in the first one .pdf                     You need to put your electrons in the first one .pdf
You need to put your electrons in the first one .pdfsanjeevtandonsre
 
PbSO4 is not generally soluble in water. It will .pdf
                     PbSO4 is not generally soluble in water. It will .pdf                     PbSO4 is not generally soluble in water. It will .pdf
PbSO4 is not generally soluble in water. It will .pdfsanjeevtandonsre
 
pH is proportional to the cell potential and it i.pdf
                     pH is proportional to the cell potential and it i.pdf                     pH is proportional to the cell potential and it i.pdf
pH is proportional to the cell potential and it i.pdfsanjeevtandonsre
 
Nitration occurs through electrophilic addition o.pdf
                     Nitration occurs through electrophilic addition o.pdf                     Nitration occurs through electrophilic addition o.pdf
Nitration occurs through electrophilic addition o.pdfsanjeevtandonsre
 
I Hope some more information required to solve th.pdf
                     I Hope some more information required to solve th.pdf                     I Hope some more information required to solve th.pdf
I Hope some more information required to solve th.pdfsanjeevtandonsre
 
What is a mistakeSolutionWhat is a mistake.pdf
What is a mistakeSolutionWhat is a mistake.pdfWhat is a mistakeSolutionWhat is a mistake.pdf
What is a mistakeSolutionWhat is a mistake.pdfsanjeevtandonsre
 
Water qualities1. Physical qualitiesOdour and taste unobject.pdf
Water qualities1. Physical qualitiesOdour and taste  unobject.pdfWater qualities1. Physical qualitiesOdour and taste  unobject.pdf
Water qualities1. Physical qualitiesOdour and taste unobject.pdfsanjeevtandonsre
 
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdfUses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdfsanjeevtandonsre
 
The moving force behind IT decisions are variable as to what context.pdf
The moving force behind IT decisions are variable as to what context.pdfThe moving force behind IT decisions are variable as to what context.pdf
The moving force behind IT decisions are variable as to what context.pdfsanjeevtandonsre
 
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdf
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdfThe Canadian city with a pre- 1800 historic heart is QuebecSolut.pdf
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdfsanjeevtandonsre
 
Solution Millennials referred to as narcissistic referred to as n.pdf
Solution Millennials referred to as narcissistic referred to as n.pdfSolution Millennials referred to as narcissistic referred to as n.pdf
Solution Millennials referred to as narcissistic referred to as n.pdfsanjeevtandonsre
 
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdf
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdfSolutionThe SELECT DISTINCT stamen will returns distinct values. .pdf
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdfsanjeevtandonsre
 
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdf
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdfStarting from the topmost column,1. Cerebellum2. Spinocerebellar.pdf
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdfsanjeevtandonsre
 
Rheumatic fever shows various symptoms and signs, out of which sore .pdf
Rheumatic fever shows various symptoms and signs, out of which sore .pdfRheumatic fever shows various symptoms and signs, out of which sore .pdf
Rheumatic fever shows various symptoms and signs, out of which sore .pdfsanjeevtandonsre
 
Physiological responce are those in which the functions of the body .pdf
Physiological responce are those in which the functions of the body .pdfPhysiological responce are those in which the functions of the body .pdf
Physiological responce are those in which the functions of the body .pdfsanjeevtandonsre
 
NaF is the only oneSolutionNaF is the only one.pdf
NaF is the only oneSolutionNaF is the only one.pdfNaF is the only oneSolutionNaF is the only one.pdf
NaF is the only oneSolutionNaF is the only one.pdfsanjeevtandonsre
 
Minimum IQ is 131SolutionMinimum IQ is 131.pdf
Minimum IQ is 131SolutionMinimum IQ is 131.pdfMinimum IQ is 131SolutionMinimum IQ is 131.pdf
Minimum IQ is 131SolutionMinimum IQ is 131.pdfsanjeevtandonsre
 

More from sanjeevtandonsre (20)

Above 70 °C, sodium bicarbonate gradually decomposes into sodium car.pdf
  Above 70 °C, sodium bicarbonate gradually decomposes into sodium car.pdf  Above 70 °C, sodium bicarbonate gradually decomposes into sodium car.pdf
Above 70 °C, sodium bicarbonate gradually decomposes into sodium car.pdf
 
You need to put your electrons in the first one .pdf
                     You need to put your electrons in the first one .pdf                     You need to put your electrons in the first one .pdf
You need to put your electrons in the first one .pdf
 
PbSO4 is not generally soluble in water. It will .pdf
                     PbSO4 is not generally soluble in water. It will .pdf                     PbSO4 is not generally soluble in water. It will .pdf
PbSO4 is not generally soluble in water. It will .pdf
 
pH is proportional to the cell potential and it i.pdf
                     pH is proportional to the cell potential and it i.pdf                     pH is proportional to the cell potential and it i.pdf
pH is proportional to the cell potential and it i.pdf
 
Nitration occurs through electrophilic addition o.pdf
                     Nitration occurs through electrophilic addition o.pdf                     Nitration occurs through electrophilic addition o.pdf
Nitration occurs through electrophilic addition o.pdf
 
I Hope some more information required to solve th.pdf
                     I Hope some more information required to solve th.pdf                     I Hope some more information required to solve th.pdf
I Hope some more information required to solve th.pdf
 
image not visible .pdf
                     image not visible                                .pdf                     image not visible                                .pdf
image not visible .pdf
 
What is a mistakeSolutionWhat is a mistake.pdf
What is a mistakeSolutionWhat is a mistake.pdfWhat is a mistakeSolutionWhat is a mistake.pdf
What is a mistakeSolutionWhat is a mistake.pdf
 
Water qualities1. Physical qualitiesOdour and taste unobject.pdf
Water qualities1. Physical qualitiesOdour and taste  unobject.pdfWater qualities1. Physical qualitiesOdour and taste  unobject.pdf
Water qualities1. Physical qualitiesOdour and taste unobject.pdf
 
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdfUses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
Uses of HRIS SystemsThe principle motivation behind keeping up HR.pdf
 
The moving force behind IT decisions are variable as to what context.pdf
The moving force behind IT decisions are variable as to what context.pdfThe moving force behind IT decisions are variable as to what context.pdf
The moving force behind IT decisions are variable as to what context.pdf
 
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdf
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdfThe Canadian city with a pre- 1800 historic heart is QuebecSolut.pdf
The Canadian city with a pre- 1800 historic heart is QuebecSolut.pdf
 
Solution Millennials referred to as narcissistic referred to as n.pdf
Solution Millennials referred to as narcissistic referred to as n.pdfSolution Millennials referred to as narcissistic referred to as n.pdf
Solution Millennials referred to as narcissistic referred to as n.pdf
 
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdf
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdfSolutionThe SELECT DISTINCT stamen will returns distinct values. .pdf
SolutionThe SELECT DISTINCT stamen will returns distinct values. .pdf
 
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdf
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdfStarting from the topmost column,1. Cerebellum2. Spinocerebellar.pdf
Starting from the topmost column,1. Cerebellum2. Spinocerebellar.pdf
 
Rheumatic fever shows various symptoms and signs, out of which sore .pdf
Rheumatic fever shows various symptoms and signs, out of which sore .pdfRheumatic fever shows various symptoms and signs, out of which sore .pdf
Rheumatic fever shows various symptoms and signs, out of which sore .pdf
 
Physiological responce are those in which the functions of the body .pdf
Physiological responce are those in which the functions of the body .pdfPhysiological responce are those in which the functions of the body .pdf
Physiological responce are those in which the functions of the body .pdf
 
NaF is the only oneSolutionNaF is the only one.pdf
NaF is the only oneSolutionNaF is the only one.pdfNaF is the only oneSolutionNaF is the only one.pdf
NaF is the only oneSolutionNaF is the only one.pdf
 
okkkSolutionokkk.pdf
okkkSolutionokkk.pdfokkkSolutionokkk.pdf
okkkSolutionokkk.pdf
 
Minimum IQ is 131SolutionMinimum IQ is 131.pdf
Minimum IQ is 131SolutionMinimum IQ is 131.pdfMinimum IQ is 131SolutionMinimum IQ is 131.pdf
Minimum IQ is 131SolutionMinimum IQ is 131.pdf
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Access Modifiers To set the access levels of variables,methods (mem.pdf

  • 1. Access Modifiers: To set the access levels of variables,methods (members of a class) we use Access Modifiers.The different types of access specifiers available are: 1. Public 2. Private 3. Protected Public: When we declare a variable, method as public, it means that we can access those from outside the class but within a program . When we inherit a class all public members of the class will be accessible by the derived class. Usage: Prefix the variable or method definition by the keyword public. Example: public: int x; public: void print(); Private: When we declare a variable, method as private, it means that we can access them only within the class. Private variables of a class can be accessed only through getter and setter methods which are public. By default the members of a class are private, if we do not specify any access modifier it is considered to be private. This is concept used to achieve encapsulation. Usage: Prefix the variable or method definition by the keyword private Example: private: int x; public: void setX(); Protected: When we declare a class, variable, method.,etc as public, it means that we can access them within the class and the class with inherits it i.e,protected members can be accessed by the derived class or child class also. Usage: Prefix the variable or method definition by the keyword protected Example: protected: int x; 1(c): class Rectangle: public Shape{ protected: string _type; public: bool isSquare() { if(width==height) return true;
  • 2. return false; } double area() { return width*height; } }; How are the Rectangle class and Shape class related? Answer: D. The Rectangle class inherits the Shape class. Solution Access Modifiers: To set the access levels of variables,methods (members of a class) we use Access Modifiers.The different types of access specifiers available are: 1. Public 2. Private 3. Protected Public: When we declare a variable, method as public, it means that we can access those from outside the class but within a program . When we inherit a class all public members of the class will be accessible by the derived class. Usage: Prefix the variable or method definition by the keyword public. Example: public: int x; public: void print(); Private: When we declare a variable, method as private, it means that we can access them only within the class. Private variables of a class can be accessed only through getter and setter methods which are public. By default the members of a class are private, if we do not specify any access modifier it is considered to be private. This is concept used to achieve encapsulation. Usage: Prefix the variable or method definition by the keyword private Example: private: int x; public: void setX(); Protected: When we declare a class, variable, method.,etc as public, it means that we can access them within the class and the class with inherits it i.e,protected members can be accessed by the derived class or child class also.
  • 3. Usage: Prefix the variable or method definition by the keyword protected Example: protected: int x; 1(c): class Rectangle: public Shape{ protected: string _type; public: bool isSquare() { if(width==height) return true; return false; } double area() { return width*height; } }; How are the Rectangle class and Shape class related? Answer: D. The Rectangle class inherits the Shape class.