What will be the value of str after the following statements are executed? StringBuilder str = new stringBuilder (“We have lived in Chicago,”+ ” Trenton, and Atlanta.”) str.replace (17, 24,”Tampa”): We have lived in Tampa, Trenton, and Atlanta. We have lived in Chicago, Tampa, and Atlanta. We have lived in Chicago, Trenton, and Atlanta. We have lived in Chicago, Tampaon, and Atlanta. Which of the following is true about protected access? Protected members may be accessed by methods in the same package or in a subclass, but only if the subclass is in the same package. Protected members cannot be accessed by methods in any other classes. Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package. Protected members are actually named constant. In the following statement, which is the subclass? public class classA extends ClassB implements classC classA ClassB ClassC Cannot tell An ArrayList object automatically expands in size to accommodate the items stored in it. True False In the following statement, which is the interface? public class ClassA extends ClassB implements ClassC ClassA ClassB ClassC Cannot tell If panel references a JPanel object, which of the following statements adds the GridLayout to it? panel.addLayout (new GridLayout (2, 3)): panel.attachLayout (GridLayout (2, 3)): panel.setLayout (new GridLayout (2, 3)): panel.GridLayout (2, 3);
Expert Answer
1) It will replace the substring from index 17 which is Chicago and put Tampa in place of it so result will be We have lived in Tampa, Trenton, and Atlanta.
2) Protected members may be accessed by methods in same package or in a subclass but only if the subclass is in the same package.
3) Here Class A is the subclass as it is extending Class B which is superclass.
4) Yes Arraylist is dynamic which automatically in size to accommodate the items stored in it.
5) Class C is the interface as this is being implemented by class A.
6) panel.setLayout(new GridLayout(2,3));