programming languages Online Quiz - 322
Description: programming languages Online Quiz - 322 | |
Number of Questions: 20 | |
Created by: Aliensbrain Bot | |
Tags: programming languages |
12 You have these files in the same directory. What will happen when you attempt to compile and run Class1.java if you have not already compiled Base.java //Base.java package Base; class Base{ protected void amethod(){ System.out.println("amethod"); }//End of amethod }//End of class base package Class1; //Class1.java public class Class1 extends Base{ public static void main(String argv[]){ Base b = new Base(); b.amethod(); }//End of main }//End of Class1
13 Which of the following statements are true?
14 Which of the following are legal statements?
15 Which of the following are valid statements?
16 Which of the following statements are true?
17 Which of the following statements are true?
18 You have a public class called myclass with the main method defined as follows public static void main(String parm[]){ System.out.println(parm[0]); } If you attempt to compile the class and run the program as follows java myclass hello What will happen?
19 Read this piece of code carefully if("String".toString() == "String") System.out.println("Equal"); else System.out.println("Not Equal");
20 Read this piece of code carefully if(" String ".trim() == "String") System.out.println("Equal"); else System.out.println("Not Equal");
Given: 11. public static void main(String[] args) { 12. try { 13. args=null; 14. args[0] = “test”; 15. System.out.println(args[0]); 16. } catch (Exception ex) { 17. System.out.println(”Exception”); 18. } catch (NullPointerException npe) { 19. System.out.println(”NullPointerException”); 20. } 21. } What is the result?
Given: 11. static classA { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println(”B “); } 16. } 17. public static void main(String[] args) { 18.A a=new B(); 19. a.process(); 20.} What is the result?
Given: 8. public class test { 9. public static void main(String [] a) { 10. assert a.length == 1; 11. } 12. } Which two will produce an AssertionError? (Choose two.)
Given: 11. public static Iterator reverse(List list) { 12. Collections.reverse(list); 13. return list.iterator(); 14. } 15. public static void main(String[] args) { 16. List list = new ArrayList(); 17. list.add(” 1”); list.add(”2”); list.add(”3”); 18. for (Object obj: reverse(list)) 19. System.out.print(obj + “,”); 20. } ‘What is the result?
Given: 11. public static void main(String[] args) { 12. String str = “null’; 13. if (str == null) { 14. System.out.println(”null”); 15. } else (str.length() == 0) { 16. System.out.println(”zero”); 17. } else { 18. System.out.println(”some”); 19. } 20. } ‘What is the result?
Given: 11. public class Bootchy { 12. int bootch; 13. String snootch; 14. 15. public Bootchy() { 16. this(”snootchy”); 17. System.out.print(”first “); 18. } 19. 20. public Bootchy(String snootch) { 21. this(420, “snootchy”); 22. System.out.print(”second “); 23. } 24. 25. public Bootchy(int bootch, String snootch) { 26. this.bootch = bootch; 27. this.snootch = snootch; 28. System.out.print(”third “); 29. } 30. 31. public static void main(String[] args) { 32. Bootchy b = new Bootchy(); 33. System.out.print(b.snootch +“ “ + b.bootch); 34. } 35. } What is the result?
Given: 10. interface Foo {} 11. class Alpha implements Foo { } 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?
Given That: 10. interface Foo {} 11. class Alpha implements Foo { } 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?
Perl was develped by
Perl is
File extension for a perl program is