answersLogoWhite

0


Best Answer

That is used to verify whether an object is based on the specified class (or a subclass).

User Avatar

Wiki User

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

Wiki User

10y ago

It is used to check whether an object is defined as being of a certain class.

This answer is:
User Avatar

Add your answer:

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

Can anyone explain How can we instanceof keyword in java?

The instanceof keyword is very self explanatory: it is used to test if an object is an instance of a particular class.Example:// Make a new String objectString str = "123";// Display a message if str is a Stringif (str instanceof String) {System.out.println("str is a String!");}Of course, the above isn't very useful since we already know str is a String. So let's look at another example:public static void f(Object obj) {if (obj instanceof String) {System.out.println("obj is a String!");} else {System.out.println("obj is NOT a String!");}}In this example, we have no idea what type of object obj will be. So we test to see if obj is a String or not.The instanceof keyword was more useful in the past (before Java 1.5) when Java didn't have the idea of generic types in it. Now it's generally considered bad practice to use the instanceof keyword, since it means we don't know what type of objects we're using.


In Java what operator is used to determine if an object is of a particular class type?

The instanceof keyword is used to determine if an object is of a particular class type.Example:Object obj = new String();if(obj instanceof String) {System.out.println("obj is a String!");}


What is mean of instanceof word in java?

'instanceof' is an operator that tests if the object to which this is applied is of a specific type or its descendent. You can safely typecast the object to the type tested if instanceof returns true.


Is check a keyword in java?

No, 'check' is not a keyword in java language.


Is float is a keyword in java?

yes, float is keyword and data type in java


How java use extern key word which is used in C plus plus?

No extern keyword in Java.


What does the verify keyword do in Java?

"verify" is not a Java keyword. I believe the link, in related links, has the complete list of Java keywords.


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 is foreign keyword in java?

There is no "foreign" keyword in Java, however, there is a native keyword that declares native methods in a native language, such as C or C++.For full list of keywords in Java see related question.


What is literal in java programming?

Literal in java are L, F, null, true, false These act as keyword(have special meaning in java) but these does'nt comes under the category of Java Keyword.


What is java's keyword for the integer data type?

"int" is the keyword for integer


Can a single Java class subclass extend both InputStream and Reader. True or False?

Java does not have multiple inheritance, so no. Java can use multiple interfaces, though, with the "implements" keyword.