课程: Java Object-Oriented Programming
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Discovering access modifiers
- In Java, we can achieve encapsulation by using access modifiers. Different access modifiers determine where certain variables and methods can be accessed in your code. In other words, they allow you to restrict to the scope of specific functionality in your program. The three different access modifiers in Java are private, protected, and public. We use these key words on pieces of a given class to give it a certain access or visibility level. Private variables and methods are only visible in the class that they live in. Protected variables and methods are visible to the package and all subclasses. Public members are accessible everywhere within the program. If no modifiers provided, it's only visible to the package it lives in. In the main class, the main method has the public access modifier. This allows it to be invoked by the JVM or Java Virtual Machine in order to execute a program. In the tree class,…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
(已锁定)
What is encapsulation?2 分钟 16 秒
-
(已锁定)
Discovering access modifiers2 分钟 35 秒
-
(已锁定)
Implementing encapsulation with access modifiers4 分钟 20 秒
-
(已锁定)
Exploring encapsulation in Java string class3 分钟 37 秒
-
(已锁定)
Challenge: Banking application1 分钟 14 秒
-
(已锁定)
Solution: Banking application4 分钟 29 秒
-
(已锁定)
-
-
-
-