0% found this document useful (0 votes)
6 views

Java Notesss

The document discusses rules and concepts related to constructors, static keywords, and abstract classes in Java. It explains that constructors initialize objects and are always public, static keywords allow for memory efficiency through shared variables and methods, and abstract classes cannot be instantiated directly and require subclasses to implement abstract methods.

Uploaded by

vaibhavrwt1802
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Java Notesss

The document discusses rules and concepts related to constructors, static keywords, and abstract classes in Java. It explains that constructors initialize objects and are always public, static keywords allow for memory efficiency through shared variables and methods, and abstract classes cannot be instantiated directly and require subclasses to implement abstract methods.

Uploaded by

vaibhavrwt1802
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

RULES:

Constructer in Java: -
1. Constructor is somewhat like a method but not exactly a method.
2. Constructor has same name as that of class.
3. There are three types of constructors:
- Parameterized constructor
- Non parameterized constructor
- Default constructor
4. Constructor does not return anything not even void, it return only and only one thing
i.e. the instance of a class.
5. Constructor is always public.
6. Constructor is always invoked when you create object of a class.
7. You can call one constructor from another constructor inside the same class for this,
this should be the first statement inside the constructor .
8. If you do not create ant constructor inside your class then JVM (java virtual machine)
will provide you a default constructor automatically which will provide you a default
constructor automatically which will be invisible to the programmer.
9. The syntax of default constructor is mentioned below:
public class Name()
{
super();
}
10. Super inside the constructor is used to call the base constructor.
11. Like method overloading is there is same way we can have constructor over loading.
12. We can write super braces this (); only once.
13. Constructor chaining is possible in java and it ends when it reaches the top most
class in java i.e., object class and that object class is responsible for returning the
instance of my class.
14. Recursive calling of constructor is not possible in java.

STATIC KEYBOARD IN JAVA: -


1. Static can be used as methods.
2. Static can be used with variables.
3. Both used to achieve memory efficiency.
4. Static variables share a common memory space between all objects.
Abstract class in Java: -
1. If a class is declared as an abstract class then you cannot create a direct instance of
that particular class.
2. Abstract class can have both abstract as well as non-abstract methods.
3. Abstract methods do not have method body, it only has declaration.
4. Abstract class provide you 0 to 100 % abstraction.
5. If you are inheriting an abstract class then it is your duty to define all methods of the
parent abstract class which are declared as abstract.
6.

You might also like