what is Encapsulation? Explaining it with real time example in Java
Code:
package com.methodOveriding;
public class Encap {
// Capsule - Class - Methods & variables
//Encapsulation - wrapping code and data together into a single unit
//The purpose of Encapsulation - Data Hiding
//Java Bean Class - private variables, getters, setters and one non-parameterized constructor
//Pojo Class - private variables, getters, setters and one parameterized constructor
private int Pepsi;
private int CocaCola;
Encap(int Pepsi,int CocaCola){
this.Pepsi=Pepsi;
this.CocaCola=CocaCola;
}
public int getPepsi() {
return Pepsi;
}
public int getCocaCola() {
return CocaCola;
}
public void setCountOfPepsi(int Pepsi) {
this.Pepsi=Pepsi;
}
public void setCountOfCocaCola(int CocaCola) {
this.CocaCola=CocaCola;
}
}
MainClass:
package com.methodOveriding;
public class EncapChildClass {
public static void main(String[] args) {
//Encap e = new Encap();
//e.setCountOfPepsi(2);
Encap e = new Encap(2,3);
System.out.println("Congratulation you have got "+e.getPepsi()+" Pepsi Bottles");
//e.setCountOfCocaCola(2);
System.out.println("Congratulation you have got "+e.getCocaCola()+" CocaCola Bottles");
}
}
Chapters:
0:00 - Introduction to the video
0:27 - Encapsulation explanation in java.
3:00 - Encapsulation explanation through a vending machine.
4:12 - Java program for encapsulation with real time example
8:30 - Explaining Java Bean Class.
9:01 - Explaining Java Pojo Class.
Next Steps :
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists
► 1. Javascript - • Javascript Factory
► 2. Puppetter - • Puppeteer
► 3. Cypress - • Cypress
► 4. Tech works - • Video
► 5. Vbscript Basics To Advanced - • VBScript Part 1 - Features Advantage...
► 6. Jmeter - • Jmeter Tutorials
► 7. Excel - • Videos On Excel
► 8. Appium - • Appium
► 9. Shares - • Shares
► 10. Javascript Interview Questions - • Javascript Interview Questions
► 11. C# Tutorials - • C# Factory
► 12. HTML & CSS - • HTML & CSS
► 13. Browser Console - • Browser Console
► 14. JSON - • Videos on Json
► 15. Specflow - • Specflow Tutorials
► 16. MongoDB - • MongoDB Tutorials
► 17. Postman - • Postman
► 18. Python - • Python
► 19. Typescript - • Typescript & Node Imp Questions
► 20. Node - • Node
► 21. Java Selenium Interview Questions: • Java and Selenium Imp
► 22. Real Time Interview Q & A: • Real Time Interview Questions
► 23.SOAP UI Tutorials : • SOAP UI
► 24. WebDriverIO : • Getting Started with WebdriverIO | In...
► 25. Jenkins : • How to download and install Jenkins o...
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
#javaprogram
#encapsulation
#reallifeexamples
On this page of the site you can watch the video online what is Encapsulation? Explaining it with real time example in Java with a duration of hours minute second in good quality, which was uploaded by the user Azhar Techno Coder 04 July 2023, share the link with friends and acquaintances, this video has already been watched 604 times on youtube and it was liked by 49 viewers. Enjoy your viewing!