Java Programing laungage

Core Java Tutorial

Introduction of Core Java

How To Install JDk and Set of Path

Syntax of java Program

Difference between Java and C/C++

Advantage and Disadvantage of Java

What is Java

Why Java is not Pure Object Oriented Language

Java has Following Features/Characteristics

Limitation of Java Language and Java Internet

Common Misconception about Java

Simple Program of Java

Integrated Development Environment in java

Compile and Run Java Program

Applet and Comments in Java

Tokens in Java

Keywords in Java

Identifier and Variables in Java

Literals/Constants

Data Type in Java

Assignments and Initialization in Java

Operators in Java

Rule of Precedence in Java

Operator on Integer and Separators in Java Programming

Java Control Flow of Statements

If and If-else Selection Statement

Nested If-else and If-else-If Selection Statement

switch case and conditional operator Selection Statement

for and while Loop

do..while and for each Loop

break and labeled break statement

continue and labeled continue statement

return Statement and exit() Method

Escape Sequence for Special Characters and Unicode Code

Constants and Block or Scope

Statement in Java

Conversions between Numeric Types in Java

Import Statement in Java

User Input in Java using Scanner Class

User Input in Java using Console Class

Array in Java

One Dimensional Array

Two Dimensional Array

Two Dimensional Array Program

Command Line Argument in Java

String args Types in Java

Uneven/Jagged array in java

Math Class Function and Constant

Math Class all Function used in a program

Enumerated Types in Java

Object Oriented Programming v/s Procedural Programming

Object Oriented Programming Concepts in Java

Introduction to Class,Object and Method in Java

Class Declaration in Java

Class & Objects in java

Encapsulation in Java

Modifiers/Visibility for a Class or Interrface or member of a Class

Polymorphism in Java

Runtime polymorphism (dynamic binding or method overriding)

adplus-dvertising
Modifiers / Visibility Labels for members of a Class
Previous Home Next

The visibility modifiers are applicable only on members of a class not on local variables.

  1. Default / no Modifier
  2. If no visibility modifier is specified before a member declaration then that member can be accessed from all the classes in the same package. That member can not be accessed outside the package.

  3. Public
  4. If we specify the modifier public with a member variable or method then that member will be visible to all classes. This memberr can be accessed even outside the package. main() method is always defined as public because the main() method is accessed by the jvm which is outside the class in which main() method is defined.

  5. Protected
  6. A member declared as protected can be accessed from all the classes belonging to the same package. Protected members can also be accessed from any sub class of other packages.

  7. Private
  8. If we specify the modifier private with a member variable then that member will not be visible outside the class in which it is declared. This will hide the member of a class from other classes.

Modifiers / Visibility for a class or Interface
  1. Public
  2. If a class is to be visible to all the classes irrespective of their package, then it must be declared as public by specifying the modifier public, which should appear before the keyword class.

  3. Default / no Modifier
  4. In the absence of any access/visibility modifier before the class, it visibility is only within the package (group of classes) it is defined.

Explain all modifiers in class
Access Modifier within class within package outside package by subclass only outside package
PrivateYNNN
DefaultYYNN
ProtectedYYYN
PublicYYYY
Previous Home Next