Skip to content

Commit 9dec14c

Browse files
author
Ram swaroop
committed
access control done
1 parent 0ddcdd2 commit 9dec14c

5 files changed

Lines changed: 84 additions & 1 deletion

File tree

_posts/2014-11-28-markdown-and-html.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: post
33
title: Markdown and HTML
4+
published: false
45
---
56

67
Jeykll supports the use of [Markdown](http://daringfireball.net/projects/markdown/syntax) with inline HTML tags which makes it easier to quickly write posts with Jekyll, without having to worry too much about text formatting. A sample of the formatting follows.

_posts/2014-11-29-feature-images.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
layout: post
33
title: Feature images
44
feature-img: "img/sample_feature_img.png"
5+
published: false
56
---
67
This is an example of a post which includes a feature image specified in the front matter of the post. The feature image spans the full-width of the page, and is shown with the title on permalink pages.

_posts/2014-11-30-sample-post.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: post
33
title: Sample post
4+
published: false
45
---
56
Consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem.
67

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
layout: post
3+
title: Access Control
4+
---
5+
6+
__Modifiers__ fall into _two_ categories:
7+
8+
* __Access modifiers__: `public, protected, private and default (package-level access)`.
9+
* __Non-access modifiers__: `transient, synchronized, native, strictfp, final, abstract and static`.
10+
11+
### Access Modifiers
12+
13+
Two __types of access__ are there:
14+
15+
* Whether method code in one class can access a member of another class
16+
* Whether a subclass can inherit a member of its superclass
17+
18+
A **default member** may be accessed only if the class accessing the member belongs to the same package,
19+
whereas a **protected member** can be accessed by a subclass in the same package _(through dot operator and inheritance)_ and even if it is
20+
is in a different package _(through inheritance only)_.
21+
22+
You cannot access a protected member using the dot (.) operator in the
23+
subclass **if the subclass is in a different package** from the parent class.
24+
25+
The following code snippet makes it clear:
26+
27+
{% highlight java %}
28+
package certification;
29+
public class Parent {
30+
protected int x = 9; // protected access
31+
}
32+
33+
package other;
34+
import certification.Parent;
35+
class Child extends Parent {
36+
public void testIt() {
37+
System.out.println("x is " + x); // No problem; Child
38+
// inherits x
39+
Parent p = new Parent(); // Can we access x using the
40+
// p reference?
41+
System.out.println("X in parent is " + p.x); // Compiler
42+
// error
43+
}
44+
}
45+
{% endhighlight %}
46+
47+
#### The below table gives the picture of all access modifiers:
48+
49+
Visibility | Public | Protected | Default | Private
50+
------------------------------------------------- | -------- | -------------------------------- | --------- | ---------
51+
From the same class | Yes | Yes | Yes | Yes
52+
From any class in the same package | Yes | Yes | Yes | No
53+
From a subclass in the same package | Yes | Yes | Yes | No
54+
From a subclass outside the same package | Yes | Yes, through inheritance | No | No
55+
From any non-subclass class outside the package | Yes | No | No | No
56+
57+
### Non-Access Modifiers
58+
59+
**Final** is the only modifier which can be applied to local variables. It can also be used in method arguments like:
60+
{% highlight java %}
61+
// final in method arguments, can't be altered inside the method
62+
public Record getRecord(int fileNumber, final int recordNumber) {}
63+
{% endhighlight %}
64+
65+
A method can never, ever, ever be marked as both **abstract and final, or both abstract and private**.
66+
67+
#### Comparison of modifiers on variables vs. methods:
68+
69+
Local Variables | Non-local Variables | Methods
70+
------------------ | ----------------------- | --------
71+
final | final | final
72+
| public | public
73+
| protected | protected
74+
| private | private
75+
| static | static
76+
| transient | abstract
77+
| volatile | synchronized
78+
| | strictfp
79+
| | native
80+

_sass/base/_variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Typography
22
$font-family-main: 'Source Sans Pro', Helvetica, Arial, sans-serif;
33
$font-family-headings: 'Source Sans Pro', Helvetica, Arial, sans-serif;
4-
$font-size: 1.25em;
4+
$font-size: 1em;
55

66
// Padding
77
$padding-large: 20%;

0 commit comments

Comments
 (0)