web technology Online Quiz - 115
web technology Online Quiz - 115
Questions
Which of the following are primitive types?
- byte
- String
- integer
- Float
Choose the technologies used in view part of MVC architecture
- HTML
- CSS
- EJB
- Servlets
Controller in PS Framework is
- ps.xml
- Action controller
- JSP file
- Servlet
Which one does not extend java.lang.Number
- Integer
- Boolean
- Character
- Long
Given: class Top { public Top(String s) { System.out.print("B"); } } public class Bottom2 extends Top { public Bottom2(String s) { System.out.print("D"); } public static void main(String [] args) { new Bottom2("C"); System.out.println(" "); } } What is the result?
- BD
- DB
- BDC
- DBC
- Compilation fails
Which statement(s) are true? (Choose all that apply.)
- Cohesion is the OO principle most closely associated with hiding implementation details
- Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs
- Cohesion is the OO principle most closely associated with making sure that a class is designed with a single, well-focused purpose
- Cohesion is the OO principle most closely associated with allowing a single object to be seen as having many types
Given: 3. class Mammal { 4. String name = "furry "; 5. String makeNoise() { return "generic noise"; } 6. } 7. class Zebra extends Mammal { 8. String name = "stripes "; 9. String makeNoise() { return "bray"; } 10. } 11. public class ZooKeeper { 12. public static void main(String[] args) { new ZooKeeper().go(); } 13. void go() { 14. Mammal m = new Zebra(); 15. System.out.println(m.name + m.makeNoise()); 16. } 17. } What is the result?
- furry bray
- stripes bray
- furry generic noise
- stripes generic noise
- Compilation fails
- An exception is thrown at runtime
Given: ClassA has a ClassD Methods in ClassA use public methods in ClassB Methods in ClassC use public methods in ClassA Methods in ClassA use public variables in ClassB Which is most likely true? (Choose the most likely.)
- ClassD has low cohesion
- ClassA has weak encapsulation
- ClassB has weak encapsulation
- ClassB has strong encapsulation
- ClassC is tightly coupled to ClassA
Given: 3. import java.io.*; 4. public class ReadingFor { 5. public static void main(String[] args) { 6. String s; 7. try { 8. FileReader fr = new FileReader("myfile.txt"); 9. BufferedReader br = new BufferedReader(fr); 10. while((s = br.readLine()) != null) 11. System.out.println(s); 12. br.flush(); 13. } catch (IOException e) { System.out.println("io error"); } 16. } 17. } And given that myfile.txt contains the following two lines of data: ab cd What is the result?
- ab
- abcd
- ab cd
- a b c D
- Compilation fails
Which is true? (Choose all that apply.)
- "X extends Y" is correct if and only if X is a class and Y is an interface
- "X extends Y" is correct if and only if X is an interface and Y is a class
- "X extends Y" is correct if X and Y are either both classes or both interfaces
- "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces
Given: 3. class A { } 4. class B extends A { } 5. public class ComingThru { 6. static String s = "-"; 7. public static void main(String[] args) { 8. A[] aa = new A[2]; 9. B[] ba = new B[2]; 10. sifter(aa); 11. sifter(ba); 12. sifter(7); 13. System.out.println(s); 14. } 15. static void sifter(A[]... a2) { s += "1"; } 16. static void sifter(B[]... b1) { s += "2"; } 17. static void sifter(B[] b1) { s += "3"; } 18. static void sifter(Object o) { s += "4"; } 19. } What is the result?
- -124
- -134
- -424
- -434
- -444
- Compilation fails
Given: 3. public class Wind { 4. public static void main(String[] args) { 5. foreach: 6. for(int j=0; j<5; j++) { 7. for(int k=0; k< 3; k++) { 8. System.out.print(" " + j); 9. if(j==3 && k==1) break foreach; 10. if(j==0 || j==2) break; 11. } 12. } 13. } 14. } What is the result?
- 0 1 2 3
- 1 1 1 3 3
- 0 1 1 1 2 3 3
- 1 1 1 3 3 4 4 4
- 0 1 1 1 2 3 3 4 4 4
- Compilation fails
Given: 3. public class TestDays { 4. public enum Days { MON, TUE, WED }; 5. public static void main(String[] args) { 6. for(Days d : Days.values() ) 7. ; 8. Days [] d2 = Days.values(); 9. System.out.println(d2[2]); 10. } 11. } What is the result? (Choose all that apply.)
- TUE
- Wed
- The output is unpredictable
- Compilation fails due to an error on line 4
- Compilation fails due to an error on line 6
- Compilation fails due to an error on line 8
What is the output of the following StringBuffer sb1 = new StringBuffer("Amit"); StringBuffer sb2= new StringBuffer("Amit"); String ss1 = "Amit"; System.out.println(sb1==sb2); System.out.println(sb1.equals(sb2)); System.out.println(sb1.equals(ss1)); System.out.println("Poddar".substring(3));
- false false false dar
- false true false Poddar
- Compiler Error
- true true false dar
Which of the following are primitive types?
- byte
- String
- integer
- Float
What is the output (Assuming written inside main) String s1 = new String("amit"); String s2 = s1.replace('m','i'); s1.concat("Poddar"); System.out.println(s1); System.out.println((s1+s2).charAt(5));
- Compile error
- amitPoddar O
- amitPoddar I
- amit I
What is the output of following (Assuming written inside main) String s1 = "Amit"; String s2 = "Amit"; String s3 = new String("abcd"); String s4 = new String("abcd"); System.out.println(s1.equals(s2)); System.out.println((s1==s2)); System.out.println(s3.equals(s4)); System.out.println((s3==s4));
- True true true false
- True true true true
- True false true false
- False false true false
Which one does not extend java.lang.Number
- Integer
- Boolean
- Character
- Long
If the method to be overridden has access type protected, choose access types among the following that a subclass can have,
- Protected
- Private
- Public
- Public & private
- Protected & Public
While serializing a class whose Base class is serializable, which of the following fields are ignored?
- Non Static field
- Base class fields
- Transient Fields
- none