answersLogoWhite

0

What is a default value?

Updated: 8/11/2023
User Avatar

Wiki User

14y ago

Best Answer

A default value is the one that has been considered the most appropriate on several

systems, methods, programs. Obviously it is the parameter which works better, otherwise it wouldn't be set as a standard value. To set something "by default" is the same as to choose a value, a configuration more convenient for that purpose.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

The protected and default access control levels are almost identical, but with one critical difference. A default member may be accessed only if the class accessing the member belongs to the same package, whereas a protected member can be accessed (through inheritance) by a subclass even if the subclass is in a different package.

Take a look at the following two classes:

package certification;

public class ClassOne {

void testIt() { // No modifier means method has default access

System.out.println("ClassOne");

}

}

In another source code file you have the following:

package otherCertification;

import certification.ClassOne;

class ClassTwo {

static public void main(String[] args) {

ClassOne o = new ClassOne();

o.testIt();

}

}

As you can see, the testIt() method in the first file has default (think: package-level) access. Notice also that class OtherClass is in a different package from the AccessClass. When you compile the ClassTwo.java file you will get an error like below:

No method matching testIt() found in class

certification.ClassOne.o.testIt();

From the preceding results, you can see that AccessClass can't use the OtherClass method testIt() because testIt() has default access, and AccessClass is not in the same package as OtherClass. So AccessClass can't see it, the compiler complains.

Default and protected behavior differs only when we talk about subclasses. If the protected keyword is used to define a member, any subclass of the class declaring the member can access it through inheritance. It doesn't matter if the superclass and subclass are in different packages, the protected superclass member is still visible to the subclass. This is in contrast to the default behavior, which doesn't allow a subclass to access a superclass member unless the subclass is in the same package as the superclass. (See the example above)

Whereas default access doesn't extend any special consideration to subclasses, the protected modifier respects the parent-child relationship, even when the child class moves away (and joins a new package). So, when you think of default access, think of package restrictions. No exceptions at all. But when you think protected, think package + kids. A class with a protected member is marking that member as having package-level access for all classes, but with a special exception for subclasses outside the package.

Tip: Remember that Default and Protected access is the same as long as inheritance is not involved.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

A default value is a value that has been considered as an appropriate value on several programs . For example by default class is always public . A default value is set as a standard value .

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a default value?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is default values of different primitive data types?

in integral data types default value=0 in decimal type default value is 0.0 in boolean default value is fa


What is default value of Boolean type variable?

False will be the default value of the boolean datatype in java


What is default value of formal arguments?

In C, there is no default value for formal parameters. In C++, there can be, but the value is whatever you declare in the function declaration.


What are the three components to data definition?

Type, name and initial value. If a value is not given and the type supports default construction, a default value is assigned.


What is the default value of a reference?

null


How is a default value set in MS Access?

When you provide a default value for a field in Access, Access will automatically insert this value into the field when a record is inserted that has no value (NULL) for this field. Default values are used when there is a sensible default for a field.


What is the difference between default and value in the configuration file of the Tibco admin?

Default is the value that has been given for a GV during design .But in Value field we can modifie the GV value during deployement.


What value is assigned to extern variable?

Default initial value of extern integral type variable is zero otherwise null.


What value is the one that a DBMS initially displays in a field?

a default value


What is the default value of integer in java?

According to the JLS, the default value of an int is 0. The default value of an object of type Integer is null. Of course, this applies only to class members fields, as local method-level fields must be explicitly assigned a value before use.


What is the default administrative value of rip?

120


Which is the default parameter passing technique in c plus plus language?

The default is to pass by value.