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
What is parse method?
Who is the owner of java?
What is main method?
There are two classes named classa and classb. Both classes are in the same package. Can a private member of classa can be accessed by an object of classb?
What is return data type?
What is the full form of jpeg?
how to deploy apache tomcat server to weblogic server in java
Can you write a java class that could be used both as an applet as well as an application?
What is an example of character?
How do you ensure that n threads can access n resources without deadlock?
How to display arraylist values in java?
What is autoboxing in java?
What about anonymous inner classes in java?
How to find the given number is a prime number or not by getting input from the user
What kind of variables can a class consist?