Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c1c66b

Browse files
authored
Merge pull request svozniuk#8 from ghost/patch-1
Improve formatting
2 parents fc50157 + e4940d5 commit 3c1c66b

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

Java Core/Java Basics.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,49 @@ Java Basics
1818

1919
4. **State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.**
2020

21-
public
22-
class -- accessible from anywhere. Can be subclassed by anyone (if not declared final)
23-
method -- accessible from anywhere. Can be overriden in subclasses.
24-
variable -- accessible from anywhere. Usually not a good practice except for the constants
25-
inner class -- accessible from anywhere.
26-
nested class-- accessible from anywhere.
27-
private
28-
class -- only for inner classes.
29-
method -- accessible only from the class where it is declared. Cannot be overridden
30-
variable -- accessible only from the class where it is declared
31-
inner class -- same
32-
nested class-- same
33-
protected
34-
class -- only for inner classes
35-
method -- accessible from the same package or from any subclass
36-
variable -- same
37-
inner class -- same
38-
nested class-- can be written but doesn't make sense (protected static!?)
39-
default(no access modifier)
40-
class -- only this package and subclasses in this package
41-
method -- same
42-
variable -- same
43-
inner class -- same
44-
nested class-- same
21+
* public
22+
class -- accessible from anywhere. Can be subclassed by anyone (if not declared final)
23+
method -- accessible from anywhere. Can be overriden in subclasses.
24+
variable -- accessible from anywhere. Usually not a good practice except for the constants
25+
inner class -- accessible from anywhere.
26+
nested class -- accessible from anywhere.
27+
* private
28+
class -- only for inner classes.
29+
method -- accessible only from the class where it is declared. Cannot be overridden
30+
variable -- accessible only from the class where it is declared
31+
inner class -- same
32+
nested class -- same
33+
* protected
34+
class -- only for inner classes
35+
method -- accessible from the same package or from any subclass
36+
variable -- same
37+
inner class -- same
38+
nested class -- can be written but doesn't make sense (protected static!?)
39+
* default (no access modifier)
40+
class -- only this package and subclasses in this package
41+
method -- same
42+
variable -- same
43+
inner class -- same
44+
nested class -- same
4545

4646
5. **What is an abstract class?**
4747

4848
An abstract class is a java class that has one or more abstract methods (no body). Abstract classes cannot be instantiated. Abstract class defines an interface that has to be implemented by all its subclasses.
4949

5050
6. **What is static in java?**
5151

52-
static is Java Language keyword.
53-
a) When used with a method defines a method of a class.
54-
b) When used with a field defines a class field.
55-
c) When used on an nested class declaration defines a static nested class.
56-
d) Also can be used for static initialization block.
52+
static is Java Language keyword.
53+
a) When used with a method defines a method of a class.
54+
b) When used with a field defines a class field.
55+
c) When used on an nested class declaration defines a static nested class.
56+
d) Also can be used for static initialization block.
5757
e) Can be used as a static initialization block
5858

5959
7. **What is final?**
6060

61-
final is Java Language keyword.
62-
a) When used with a method protects it from being overridden in subclasses. Done for security and/or performance reasons.
63-
b) When used with a field means that the value stored in the field cannon be changed after initialization. Not to be confused with immutability of the object.
61+
final is Java Language keyword.
62+
a) When used with a method protects it from being overridden in subclasses. Done for security and/or performance reasons.
63+
b) When used with a field means that the value stored in the field cannon be changed after initialization. Not to be confused with immutability of the object.
6464
c) When used with a class declaration protects it from being subclassed. Done for security and/or performance reasons. Also for immutability. Many of Java core classes are final (e.g. String)
6565

6666
8. **How can one prove that the array is not null but empty using one line of code?**
@@ -462,4 +462,4 @@ Main method
462462

463463
9. **Can main method be declared final?**
464464

465-
Yes it can be declared as final.
465+
Yes it can be declared as final.

0 commit comments

Comments
 (0)