Java: Can block locks be polymorphic?

In the article that I am going to conduct for the second exam, they ask me: "Can blocks be polymorphic?"

If true, it makes no sense for me to call several blocks catchpolymorphic. Is this a polymorphism if the blocks catchcannot be named and contain only parameters in the method header?

For instance:

try {

//...

} catch (FileNotFoundException e) {
    System.err.println("FileNotFoundException: " + e.getMessage());
    throw new SampleException(e);

} catch (IOException e) {
    System.err.println("Caught IOException: " + e.getMessage());
}

Are these two blocks catchpolymorphic in this?

+4
source share
4 answers

. , , - , .

" catch" .

  • catch, , .

try{


} catchwith ( catchHandlerObject );

catchHandlerObject . - (runtime) catchHandlerObject.

class C{
   public void m(Object o){ .... };
}

m(Object o) ? , , . m( stringObject ). .

. . - .

, . , , .

, . catch . , .

+3

?

"" , catch , , . catch - . , : , IOException.

+2

catch : " , " - , true instanceof.

, , .

+2

try , FileNotFoundException FileNotFoundException, catch.

try , IOException IOException, FileNotFoundException FileNotFoundException, catch.

try , catch .

, , , , , , .

+1

All Articles