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

Can we create an object of private class?

549


What is square root in java?

588


How do I enable java in safari?

549


What is the difference between yield() and sleep()?

543


What is the difference between static class and normal class?

494






Explain about serializable interface in java?

586


How do you convert string to int in java?

564


Write a program to find the greatest of three numbers in java?

565


Differentiate between a class and an object.

565


What are the advantages of autoboxing?

539


What's the difference between an abstract class and interface in java?

559


Explain java code for recursive solution's base case?

574


Can a list be null in java?

544


Why string is not a wrapper class?

646


Can we have return statement in finally clause? What will happen?

517