‹ Back to the paper
Question 31
1 mark
Computer ScienceISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024)Short answerInheritance, Interfaces and Polymorphism
Answer the following question.
In the given code snippet, which feature of object-oriented programming concept is being exhibited…
In the given code snippet, which feature of object-oriented programming concept is being exhibited by the substring( ) method?
String s1 = "sandwich";
System.out.println(s1.substring(4));
System.out.println(s1.substring(1,4));Answer
Answer
It exhibits method overloading (compile time/static polymorphism): the class String has two versions of substring( ) - substring(int) and substring(int, int) - with the same name but a different number of parameters.