programming languages Online Quiz - 128
programming languages Online Quiz - 128
Questions
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"); }
- default
- default, zero
- error default clause not defined
- no output displayed
Which of the following statements are true?
- Methods cannot be overriden to be more private
- static methods cannot be overloaded
- private methods cannot be overloaded
- An overloaded method cannot throw exceptions not checked in the base class
Which of the following will output -4.0
- System.out.println(Math.floor(-4.7));
- System.out.println(Math.round(-4.7));
- System.out.println(Math.ceil(-4.7));
- System.out.println(Math.min(-4.7));
String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd));
- Bic
- ic
- icy
- error: no method matching substring(int,char)
What is the result of the following operation? System.out.println(4 | 3);
- 6
- 0
- 1
- 7
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?
- s3=s1 + s2
- s3=s1 - s2
- s3=s1 & s2
- s3=s1 && s2
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); } }
- 0
- 1
- 2
- -1
How are this() and super() used with constructors?
- This() is used to invoke a constructor of the same class. super() cannot invoke a superclass constructor.
- Super() is used to invoke a constructor of the same class. This() is used to invoke a superclass constructor.
- This() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.
- None of the above.
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
- a,f,g,b
- a,g,b
- a,b,c,d,e,f
- c,a,f,g,b
- e,a,f,g,b
- d,a,f,g,b
We can have more than one validation.xml in an application?
- True
- False
Which one we prefer in validating dynamic row functionality of our application?
- Javascript
- struts validator
- cannot validate
- dynamic rows cannot be done in JSP
How you will display validation fail errors on jsp page?
- none
- <html:messages/>
- <html:errors/>
- both
We can create our our own custom validations in Struts Validator framework?
- True
- False
Which of the following will give the output as 3?
- (abs (sqrt 8))
- (modulo (ceiling (sqrt 8)) 2)
- (max (floor (sqrt 8)) (round (sqrt 8)))
- (min (truncate (sqrt 8)) (abs (sqrt 8)))
(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
- 5
- 0
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))))
- (i) & (ii)
- (i) & (iii)
- (i) only
- (i), (iii) & (iv)
6.What is output of following: ((lambda x x) 1 2 3)
- (1 2 3)
- 6
- 3
- (1 2)
3.What is output of following? (define a 97) (integer->char (exact->inexact a))
- #\97
- #\b
- #\a
- Compile time error
(modulo -15 4) the output will be:
- 3
- -3
- 1
- -1
(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 2 3 4 5 6))
- (1 2 3 4 5 6)
- ()
- (4 5 6 1 2 3)