Please answer 15-17 Please answer 18 Please answer 19-20 15. Suppose s is a stri
ID: 3574235 • Letter: P
Question
Please answer 15-17Please answer 18
Please answer 19-20 15. Suppose s is a string with the value "java". What will be assigned to x if you execute the following code? char x s.charAt(4); a. 'a' b. 'v' c. Nothing will be assigned to x, because the execution causes the runtime error StringIndexoutofBoundsException. d. None of above 16. If a class named Student has a constructor Student (String name defined explicitly, the following constructor is implicitly provided a. public Student (0 b. protected Student0 c. private Student0 d. Student() e. None 17. Suppose the xMethodo is invoked from a main method as follows, xMethod0 is public static void main(Stringl] args) xMethodO; a. a static method b. an instance method c. None of the above
Explanation / Answer
answer 15> option C because string "java" spans on indices from 0 to 3
answer 16> option E because even though a class provides its default constructor, but when a parametrized constructor is defined in the class,
then you need to define default constructor also in order to call it.
So, writing the below code will give compilation error as: "The constructor Student() is undefined"
Student s=new Student();
answer 17> option A because static methods can call other static methods directly by their name, that is, without using the object;
answer 18> option D because class B is extending class C and also implementing A.
answer 19> your options are given wrong.But I can tell you the answer. The output will be :
The default constructor of A is invoked
The default constructor of B is invoked
Answer 20> It will give compilation error saying "cannot instantiate the type A" because you can only create the reference variable of the abstract class,
but cannot instantiate it.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.