answersLogoWhite

0

What is the use of default keyword?

Updated: 10/27/2022
User Avatar

Wiki User

12y ago

Best Answer

default is used with (switch statement) to handle what'll happen if non of the defined cases happened.

ex:

int x=4;

switch(x)

{

case 1: cout<<"1"; break;

case 2: cout<<"2"; break;

case 3: cout<<"3"; break;

default : cout<<"It's not 1 or 2 or 3 ..! ";

}

in that case .. we'll see (It's not 1 or 2 or 3 ..!)

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the use of default keyword?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the use o keyword import?

When we want to use classes of packages other than the default package and java.lang, we should import them. Example : import java.util.Scanner;


Which keyword can protect a class in a package from accessibility by the classes outside the package?

default


Why don't use abstract keyword when we declare a method in interface?

The abstract keyword signifies that the particular method will have no features in the class where it is declared and it is upto the child class to provide the functionality. In case of an interface, the method is already abstract by default and has no code inside it. So there is no actual point in using the abstract keyword there.


What is the use of keyword new used in AWT programming?

what is the use of new keyword in awt programming


Which keyword do you use to deallocate memory that has been assigned to a stream object?

Delete keyword


What is the purpose of transient keyword in Java?

A variable which is declared as transient will not be serialized. This means that when you use an ObjectOutputStream to store the current state of a class, anything labeled as transient will be skipped over.A common use of this keyword is to ensure that sensitive user information (usernames, passwords, etc.) is not accidentally saved to a file.


Can you declears static in a local variable in a method in java?

we cannot use the staic keyword inside the method... But we can use the final keyword inside the method....


What are the 6 ways to use this keyword?

"Java This keyword" is a reference to the current object, it is very helpful when you need to refer an instance of a particular Object from its available methods or using it's constructor, also "this" keyword helps us to avoid naming conflicts.The following are different ways to use java this keyword1) Using with instance variable2) Using with Constructor3) Pass / Return current instanceUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with ConstructorUsing this keyword inside constructor like followingthis("Sony", 20); it will call the constructor having same parameter


How many keywords you can use for link building?

You can use many keyword for link building, but you should use an LSI keyword so, you will better to give links on your keyword. The idea is to find as many qualifiers as possible that fit your audience. http://socialseoteam.com/link-building-2015.php


What is the default for html font weight?

The "default" weight is dependent on the browser. But the general weight used is identified in CSS by the keyword "normal" or the number 400. The CSS looks like this .yourClass { font-weight: normal;} or .yourClass {font-weight: 400;} Users can change the default in the browser itself, but it's rare.


How are the keywords struct and class different?

The keyword class is not a keyword in C. It is a keyword in C++, so I have added C++ to the category list for this question.The default access specifier for struct is public, while for class, it is private.Struct does not allow you to specify methods, while class does.A struct is not a class, and cannot be derived, while a class can be treated as a struct, if the scope and access is correct.


Is super keyword is anologous to this keyword in java?

No. The keyword super is used to refer to the parent class instance while the keyword this is used to refer to the current class instance. You need to learn about Inheritance and Object creation using constructors to learn more about these keywords and their use