Life long sharing . . .

Java – Modifier Types

Posted on: November 22, 2015

Another thing to learn about Java programming language is “Modifier Types”. This website: http://www.tutorialspoint.com/java/java_modifier_types.htm has a very good coverage of it.

Lesson4-note1

Let’s try some quiz on the Java Control Access Modifier.

Quiz 1:

Lesson4-code1

Note: use below command to compile and classes in package

compile

For the codes in the main method in AnotherClass class, which lines are valid and which lines are not?

Valid:

Not valid:

Quiz 2:

Lesson4-code2

What is the output of the above codes?

Output:

Quiz 3:

Lesson4-code3

Try to run the above codes. What did you get? How to fix it?

.

Lesson4-note2

Here are details of final, abstract and synchronized modifiers. It might look a bit hard to comprehend now, but we will come to them again in future.

Final:

Lesson4-note3

Abstract:

Lesson4-note4

Synchronized:

Lesson4-note5

 

Advertisements

1 Response to "Java – Modifier Types"

Quiz 1 : Valid : Line 1 and line 4
Not valid : Line 2 and line 3
Quiz 2 : hello! welcome!
10
Quiz 3 : 2 errors, change ‘private’ from line 5 to ‘protected’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives

November 2015
M T W T F S S
« Oct   Dec »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 180 other followers

%d bloggers like this: