Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

default
keyword
java8
access-modifiers

Default keyword in Java 8

Educative Answers Team

There are many keywords in Java. One of them is the word default. The word default is an access-modifier. If a user does not assign any access-modifier to a class or its variables, Java, by default, assigns them the default access-modifier.

svg viewer

Overview

The following table compares the accessibility of different access-modified variables:

Modifier Class Package Sub-class Global
Public Yes Yes Yes Yes
Private Yes No No No
Default Yes Yes No No
Protected Yes Yes Yes No

Note: default String s1 and String s1 is the same thing. As discussed earlier, when no access-modifier is mentioned, Java 8, by default, assumes the variable to be a default variable. Hence, default does not need to be explicitly written.

RELATED TAGS

default
keyword
java8
access-modifiers
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring