wHAT IS DEFAULT SPECIFIER IN JAVA
wHAT IS DEFAULT CONSTRUCTOR IN JAVA
wHAT IS DEFAULT METHOD IN JAVA

Answer Posted / srinu

DEFAULT SPECIFIER IN JAVA:
There are 4 types of accessibility specifier in java, they
are private,public,protected and default.
There is no key word in java to specify default specifier
When we do not specify any specifier which means default
specifier,the default specifier access the with in package
only.
EX:- public void setName(String name)
{
this.name=name;
}
The above method access any class or any package
void setName(String name)
{
this.name=name;
}
The above method can access with in package.

DEFAULT CONSTRUCTOR IN JAVA:-
THE default constructor in java is System default constructor.

EX:-
public class A
{
String name;
public void setName(String name);
{
this.name=name;
}
}
The above program their is no constructor .then that time
java compiler created default constructor.

Note: we can interested see default constructor frist we
compile java program(javac A.java) after javap A.Then that
time u watch system default constructor.

DEFAULT METHOD IN JAVA:--
The dafault method in java is super().
EX:-
public class A
{
A()
{
System.out.println("IAM CONSTRUCTOR FROM CLASS A ");
}
}
public class B extends A
{
B()
{
System.out.println("IAM CONSTRUCTOR FROM CLASS B");
}
public static void main(String k[])
{
B b=new B();
}
}
output:-
IAM CONSTRUCTOR FROM CLASS A
IAM CONSTRUCTOR FROM CLASS B
hence super() method is default method

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is empty string in java?

825


What is the use of 'super' keyword inside a constructor?

756


What are inbuilt functions in java?

797


What is constructor chaining and how is it achieved in java?

792


What are the 4 types of research methods?

702


Why wait and notify methods are declared in object class?

803


what state does a thread enter when it terminates its processing? : Java thread

823


What is the difference between array and array list in java?

803


What are the data types supported by java? What is autoboxing and unboxing?

770


What is java Applet?

833


What does it mean that a class or member is final?

760


What is internal iteration in java se 8?

873


What is local variable and instance variable?

814


What is string literal in java?

789


What is method overloading and method overriding?

766