programming languages Online Quiz - 128

programming languages Online Quiz - 128

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What will be printed out if you attempt to compile and run the following code? int i=9; switch (i) { default: System.out.println("default"); case 0: System.out.println("zero"); break; case 1: System.out.println("one"); case 2: System.out.println("two"); }

  1. default
  2. default, zero
  3. error default clause not defined
  4. no output displayed
Question 2 Multiple Choice (Multiple Answers)

Which of the following statements are true?

  1. Methods cannot be overriden to be more private
  2. static methods cannot be overloaded
  3. private methods cannot be overloaded
  4. An overloaded method cannot throw exceptions not checked in the base class
Question 3 Multiple Choice (Single Answer)

Which of the following will output -4.0

  1. System.out.println(Math.floor(-4.7));
  2. System.out.println(Math.round(-4.7));
  3. System.out.println(Math.ceil(-4.7));
  4. System.out.println(Math.min(-4.7));
Question 4 Multiple Choice (Single Answer)

String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd));

  1. Bic
  2. ic
  3. icy
  4. error: no method matching substring(int,char)
Question 5 Multiple Choice (Single Answer)

What is the result of the following operation? System.out.println(4 | 3);

  1. 6
  2. 0
  3. 1
  4. 7
Question 6 Multiple Choice (Multiple Answers)

Given the following declarations String s1=new String("Hello") String s2=new String("there"); String s3=new String(); Which of the following are legal operations?

  1. s3=s1 + s2
  2. s3=s1 - s2
  3. s3=s1 & s2
  4. s3=s1 && s2
Question 7 Multiple Choice (Single Answer)

What gets printed when the following code is compiled and run. Select the one correct answer. public class test { public static void main(String args[]) { int i = 1; do { i--; } while (i > 2); System.out.println(i); } }

  1. 0
  2. 1
  3. 2
  4. -1
Question 8 Multiple Choice (Single Answer)

How are this() and super() used with constructors?

  1. This() is used to invoke a constructor of the same class. super() cannot invoke a superclass constructor.
  2. Super() is used to invoke a constructor of the same class. This() is used to invoke a superclass constructor.
  3. This() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.
  4. None of the above.
Question 9 Multiple Choice (Single Answer)

Identify the steps to integrate validator framework in struts? a)Copy validation.xml and validation rules.xml to web-inf directory b)Add errors in resource bundle c)Include validation plug-ins in struts- config.xml d)Add validation plug-ins in web.xml and struts-config.xml e)Add validation plug ins in web.xml f)Include the required form in tag in validation.xml g)include required fields in

tag in validation.xml

  1. a,f,g,b
  2. a,g,b
  3. a,b,c,d,e,f
  4. c,a,f,g,b
  5. e,a,f,g,b
  6. d,a,f,g,b
Question 10 True/False

We can have more than one validation.xml in an application?

  1. True
  2. False
Question 11 Multiple Choice (Single Answer)

Which one we prefer in validating dynamic row functionality of our application?

  1. Javascript
  2. struts validator
  3. cannot validate
  4. dynamic rows cannot be done in JSP
Question 12 Multiple Choice (Single Answer)

How you will display validation fail errors on jsp page?

  1. none
  2. <html:messages/>
  3. <html:errors/>
  4. both
Question 13 True/False

We can create our our own custom validations in Struts Validator framework?

  1. True
  2. False
Question 14 Multiple Choice (Single Answer)

Which of the following will give the output as 3?

  1. (abs (sqrt 8))
  2. (modulo (ceiling (sqrt 8)) 2)
  3. (max (floor (sqrt 8)) (round (sqrt 8)))
  4. (min (truncate (sqrt 8)) (abs (sqrt 8)))
Question 15 Multiple Choice (Single Answer)

(define myList (list 1 2 3 4 5 6 7 8 9)) (- (+ (list-ref mylist 2) (cadr mylist)) (list-ref (cddr mylist) 2)) Output of the above code will be:

  1. 1
  2. -1
  3. 5
  4. 0
Question 16 Multiple Choice (Single Answer)

Which of the following codes will NOT give an error? (i) (display '(1 2 3)) (ii) (display (* (exp 5 2) 2)) (iii) (display (* (expt 5 2) 2)) (iv) (display (+ 5 (display (* 4 2))))

  1. (i) & (ii)
  2. (i) & (iii)
  3. (i) only
  4. (i), (iii) & (iv)
Question 17 Multiple Choice (Single Answer)

6.What is output of following: ((lambda x x) 1 2 3)

  1. (1 2 3)
  2. 6
  3. 3
  4. (1 2)
Question 18 Multiple Choice (Single Answer)

3.What is output of following? (define a 97) (integer->char (exact->inexact a))

  1. #\97
  2. #\b
  3. #\a
  4. Compile time error
Question 19 Multiple Choice (Single Answer)

(modulo -15 4) the output will be:

  1. 3
  2. -3
  3. 1
  4. -1
Question 20 Multiple Choice (Single Answer)

(define list1 (list 1 2 3)) (define list2 (list 4 5 6)) (define list3 (list)) (append list3 list1 list2) what will be the output if we display list3?

  1. ((1 2 3 4 5 6))
  2. (1 2 3 4 5 6)
  3. ()
  4. (4 5 6 1 2 3)