Which of the following is a valid declaration of a generic method ?A public static<X,Y extends X> boolean isPresent(X x,Y[] y){}
B public static<X,Y extends X>static boolean isPresent(X x,Y[] y){}
C public static boolean<X,Y extends X>isPresent(X x,Y[] Y){}
D None of these
Choice A is the correct answer
generic methods are methods that are parameterized by one or more type parameters.Generic methods allow type parameters to be used to express dependecies among the types of one or
more arguments to a method and/or its return type.The type parameters must be declared before th return type of the method,but after the modifiers.This condition is satisfied by choice A, But not by choices B and C.So choices B C and D are incorrect.
B public static<X,Y extends X>static boolean isPresent(X x,Y[] y){}
C public static boolean<X,Y extends X>isPresent(X x,Y[] Y){}
D None of these
Choice A is the correct answer
generic methods are methods that are parameterized by one or more type parameters.Generic methods allow type parameters to be used to express dependecies among the types of one or
more arguments to a method and/or its return type.The type parameters must be declared before th return type of the method,but after the modifiers.This condition is satisfied by choice A, But not by choices B and C.So choices B C and D are incorrect.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货