News Ticker

Menu

Browsing "Older Posts"

Browsing Category "Javascript"

UpWork (oDesk) & Elance Spring MVC Test Question & Answers

July 03, 2015 / No Comments
UpWork (oDesk) & Elance Spring MVC Test Question & Answers are really very important to pass UpWork & Elance test. You will get top score at this skill test exam. If you found any problem or wrong answer please inform me via contact or comments. We will try to solve it in short. This test is extremely valuable to acquire knowledge of Spring MVC. Lets Start test.


Ques : In an annotation-based Spring MVC controller, which of the following are valid ways to set cache headers for a specific path?
Ans  :  Ensuring the instance of "AnnotationMethodHandlerAdapter" does not have the    "cacheSeconds" property set, and adding an instance of "WebContentInterceptor".
       Adding "final HttpServletResponse response" as a parameter, then setting the header "Cache-Control" to "all-cache".
       Using a Handler Interceptor and using the "postHandle" method provided by it.

Ques : Which of the following are valid sets of constructor arguments for the ModelAndView class? (Select all correct answers.)
Ans  :  String viewName
        String viewName, Map model

Ques :  Which of the following are possible validation methods for user input in Spring MVC?
Ans  :  Annotation validation
        Programmatic validation

Ques : Which of the following code samples will get the ServletContext inside an Interceptor?
Ans  : @Autowired ServletContext context;
       request.getSession().getServletContext();

Ques : Which of the following dependency injection (DI) methodologies are available in Spring MVC?
Ans  : Constructor-based dependency injection
       Setter-based dependency injection

Ques : Which of the following interfaces can be implemented to interact with a container's management of the bean lifecycle?
Ans  : InitializingBean
       DisposableBean

Ques : Select all authentication methods that are supported by Spring Security by default:
Ans  : Basic Authentication
       Digest Access Authentication

Ques : True or false: a factory class can hold more than one factory method.
Ans  : True

Ques : Regarding the @Resource annotation, which of the following statements is false?
Ans  :  If no name attribute is specified, the default name is derived from the field name or setter method.

Ques : Which of the following  statements is true about method arguments that have an @ModelAttribute annotation?
Ans  :  Model attributes have to be explicitly added when using @ModelAttribute.

Ques : What does the following code do?

@RequestMapping("/{id}/**")
public void foo(@PathVariable("id") int id, HttpServletRequest request) {
    String restOfTheUrl = (String) request.getAttribute(
        HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    ...
}
Ans  :  It retrieves the partial path value (after "**") before the @RequestMapping and @PathVariable values have been parsed.

Ques : Which of the following can be used to serve static resources while still using DispatchServlet at the site's root?
Ans  :

Ques : What is the difference between the @Repository and the @Controller annotations in Spring?
Ans  : "@Repository" is used as a stereotype for the persistence layer, while "@Controller" is used as a stereotype for the presentation layer.

Ques : Which of the following annotations are supported by classes with the @Bean annotation?
Ans  :  @PostConstruct

Ques : Which of the following statements is false?
Ans  : By default, a transaction is only marked for rollback in the case of runtime unchecked exceptions.

Ques :  Which of the following statements is true about the HandlerExceptionResolver class?
Ans  : DefaultHandlerExceptionResolver converts standard Spring exceptions and converts them to HTTP Status Codes.

Ques : Given the following method:

@RequestMapping(method=RequestMethod.GET, value="/fooBar")
    public ResponseEntity fooBar2() {
      String json = "jsonResponse";
      HttpHeaders responseHeaders = new HttpHeaders();
      responseHeaders.setContentType(MediaType.APPLICATION_JSON);
      return new ResponseEntity(json, responseHeaders, HttpStatus.CREATED);
    }

Which of the following statements is correct?
Ans  : It returns a JSON String and sets the mimetype to text/javascript.

Ques : Which of the following classes provides built-in pagination functionality in SpringMVC?
Ans  : PagedListHolder

Ques : Given the method below:

@RequestMapping(value = "/foo", method = RequestMethod.GET)
public final String foo(HttpServletRequest request, BindingResult bindResult, ModelMap model) {
    model.addAttribute("abc", 123);
    return "foo";
}

When the view is displayed in the browser, it's URL is "http://mydomain/foo?abc=123".

Which of the following statements is true?
Ans  : The attribute name-value pair will be included in the URL, regardless of the use of @ModelAttribute in the controller.

Ques : Which of the following is true about the use of in a servlet?
Ans  :   activates many different annotations in beans, whether they are defined in XML or through component scanning.

Ques : Fill in the blank:
The _______ enables the use of the bean element’s attributes, instead of nested elements, to describe property values and/or collaborating beans.
Ans  : p-namespace

Ques : Which of the following statements is true about the @RequestMapping annotation?
Ans  : It supports ant-style paths.

Ques : Which of the following statements is true for the configuration of the Spring handler adapter(s) in a Spring MVC application context?
Ans  : If at least one request handler adapter is defined the context files, Spring will not create the default adapters.

Ques : Which of the following statements is true about the HandlerInterceptor interface?
Ans  : It allows exchanging the request and response objects that are handed down the execution chain.

Ques : How can an HTTP 404 status code be returned from a Spring MVC Controller?
Ans  : Having the method accept HttpServletResponse as a parameter, so that setStatus(404) can be called on it.

Ques : Which of the following is the default bean scope in Spring MVC?
Ans  : singleton

Ques : Which of the following enables custom qualifier annotation types to be registered even if they are not annotated with Spring’s @Qualifier annotation?
Ans  : CustomAutowireConfigurer

Ques : Which of the following statements is correct?
Ans  : doesn't declare its own handler mapping

Ques : Which of the following statements is true about the @RequestParam annotation?
Ans  : It indicates that a method parameter should be bound to a web request parameter.

Ques : Which of the following code samples will correctly return an image in @ResponseBody from a byte[] of image data?
Ans  : @ResponseBody @RequestMapping("/photo", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE) public byte[] testphoto() throws IOException { InputStream in = servletContext.getResourceAsStream("/images/no_image.jpg"); return IOUtils.toByteArray(in); }

Ques : Which of the following statements are correct, with respect to using the @PreAuthorize annotation in Spring controller methods?
Ans  : @PreAuthorize works with Spring controller methods.

Ques : Which of the following is not a built-in Spring MVC bean scope?
Ans  : local session

Ques : Fill in the blank: _______ is a class-level annotation indicating that an object is a source of bean definitions.
Ans  : @Configuration

Ques : Fill in the blank:
When defining a bean that is created with a static factory method, the ______ attribute is used to specify the class containing the static factory method.
Ans  : class

Ques : Which of the following statements is true about the @ModelAttribute annotation?
Ans  : It can be used to expose reference data to a web view.

Ques : Fill in the blank:
In Spring's XML-based configuration, the _______ attribute of the element specifies a property or constructor argument as a string representation.
Ans  : name

Ques : Which of the following statements is/are true about autowiring in Spring?
Ans  : Fields are injected after the construction of a bean.

Thanks for watching this test Question & Answers. Please don't forget to leave a comment about this post. You can also find some more effective test question & answers, information, techniques, technology news, tutorials, online earning information, recent news, results, job news, job exam results, admission details & another related services on the following sites below. Happy Working!
News For Todays ARSBD oEtab ARSBD-JOBS DesignerTab

UpWork (oDesk) & Elance JavaScript Test Question & Answers

June 28, 2015 / No Comments
UpWork (oDesk) & Elance JavaScript Test Question & Answers are really very important to pass UpWork & Elance test. You will get top score at this skill test exam. If you found any problem or wrong answer please inform me via contact or comments. We will try to solve it in short. This test is extremely valuable to acquire knowledge of this skill. Lets Start test.



Ques : Which of the following prints "AbBc"?
Ans  : var b = 'a'; var result = b.toUpperCase() + 'b' + 'b'.toUpperCase() +'C'['toLowerCase'](); alert(result);

Ques : Performance-wise, which is the fastest way of repeating a string in JavaScript?
Ans  : String.prototype.repeat = function(count) { if (count < 1) return ''; var result = '', pattern = this.valueOf(); while (count > 0) { if (count & 1) result += pattern; count >>= 1, pattern += pattern; } return result; };

Ques : What is the final value of the variable bar in the following code?

var foo = 9;
bar = 5;
(function() {
    var foo = 2;
    bar= 1;
}())
bar = bar + foo;
Ans  : 10

Ques : Which of the following code snippets changes an image on the page?
Ans  : var img = document.getElementById("imageId"); img.src = "newImage.gif";

Ques : Which of the following results is returned by the JavaScript operator "typeof" for the keyword "null"?
Ans  : object

Ques : Which of the following will check whether the variable vRast exists or not?
Ans  :  if (typeof vRast =="undefined") {}

Ques : Which of the following choices will change the source of the image to "image2.gif" when a user clicks on the image?
Ans  : img id="imageID" src="image1.gif" width="50" height="60" onmousedown="changeimg(image1.gif)" onmouseup="changeimg(image2.gif)"

Ques :  Which of the following Regular Expression pattern flags is not valid?
Ans  : p

Ques : Which of the following statements is correct?
Ans  : Undefined object properties can be checked using the following code: if (typeof something === "undefined") alert("something is undefined");

Ques : Which of the following choices will turn a string into a JavaScript function call (case with objects) of the following code snippet?

Ans  : window['foo']['bar']['baz']();

Ques : Which of the following options can be used for adding direct support for XML to JavaScript?
Ans  : E4X

Ques : Which of the following will detect which DOM element has the focus?
Ans  : document.activeElement

Ques : Which of the following will randomly choose an element from an array named myStuff, given that the number of elements changes dynamically?
Ans  :  randomElement = myStuff[Math.floor(Math.random() * myStuff.length)];

Ques : Which of the following objects in JavaScript contains the collection called "plugins"?
Ans  : Navigator

Ques : What is the difference between call() and apply()?
Ans  : The call() function accepts an argument list of a function, while the apply() function accepts a single array of arguments.

Ques : Select the following function that shuffles an array?
Ans  :  function shuffle(array) { var tmp, current, top = array.length; if(top) while(--top) { current = Math.floor(Math.random() * (top + 1)); tmp = array[current]; array[current] = array[top]; array[top] = tmp; } return array; }

Ques : Which of the following code snippets removes objects from an associative array?
Ans  : delete array["propertyName"];

Ques : What is the error in the statement: var charConvert = toCharCode('x');?
Ans  :  toCharCode() is a non-existent method.

Ques : What does the following JavaScript code do?

contains(a, obj) {
    for (var i = 0; i < a.length; i++) {
        if (a[i] === obj) {
            return true;
        }
    }
    return false;
}
Ans  :  It checks if an array contains 'obj'.

Ques : If an image is placed styled with z-index=-1 and a text paragraph is overlapped with it, which one will be displayed on top?
Ans  : The paragraph.

Ques : Which of the following code snippets gets an image's dimensions (height & width) correctly?
Ans  : var img = document.getElementById('imageid'); var width = img.clientWidth; var height = img.clientHeight;

Ques : var profits=2489.8237

Which of the following code(s) produces the following output?

output : 2489.824
Ans  : profits.toFixed(3)

Ques : A form contains two fields named id1 and id2.  How can you copy the value of the id2 field to id1?
Ans  : document.forms[0].id1.value=document.forms[0].id2.value

Ques : Which of the following is true about setTimeOut()?
Ans  : The statement(s) it executes run(s) only once.

Ques : How can the operating system of the client machine be detected?
Ans  :  Using the navigator object

Ques : Which of the following descriptions is true for the code below?

var object0 = {};
Object.defineProperty(object0, "prop0", { value : 1, enumerable:false, configurable : true });
Object.defineProperty(object0, "prop1", { value : 2, enumerable:true,  configurable : false });
Object.defineProperty(object0, "prop2", { value : 3 });
object0.prop3 = 4;
Ans  : Object 'object0' contains 4 properties. Property 'prop1' and property 'prop3' are available in the for...in loop. Property 'prop0' and property 'prop3' are available to delete.

Ques : Consider the following variable declarations:

var a="adam"
var b="eve"

Which of the following would return the sentence "adam and eve"?
Ans  : a.concat(" and ", b)

Ques : Which object can be used to ascertain the protocol of the current URL?
Ans  : location

Ques : Which of the following best describes a "for" loop?
Ans  : "for" loop consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.

Ques : Which of the following is not a valid HTML event?
Ans  :  onblink

Ques : Which of the following are JavaScript unit testing tools?
Ans  : Buster.js, YUI Yeti, Jasmine

Ques : Which of the following can be used for disabling the right click event in Internet Explorer?
Ans  :  event.button == 2

Ques : Which of the following Array methods in JavaScript runs a function on every item in the Array and collects the result from previous calls, but in reverse?
Ans  : reduceRight()

Ques : What will be the final value of the variable "apt"?

var apt=2;
apt=apt<<2 b="">
Ans  : 8

Ques :  How can a JavaScript object be printed?
Ans  : console.log(obj)

Ques : Which of the following is the correct syntax for using the JavaScript exec() object method?
Ans  : RegExpObject.exec(string)

Ques : Having an array object var arr = new Array(), what is the best way to add a new item to the end of an array?
Ans  : arr.push("New Item")

Ques : Consider the following JavaScript validation function:
function ValidateField()
{
        if(document.forms[0].txtId.value =="")
                {return false;}

        return true;
}
Which of the following options will call the function as soon as the user leaves the field?
Ans  :  input name=txtId type="text" onblur="return ValidateField()"

Ques : Which of following uses the "with" statement in JavaScript correctly?
Ans  : with (document.getElementById("blah").style) { background = "black"; color = "blue"; border = "1px solid green"; }

Ques : Which of the following modifiers must be set if the JavaScript lastIndex object property was used during pattern matching?
Ans  : g

Ques : What would be the use of the following code?

function validate(field) {
    var valid=''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'';
    var ok=''yes'';
    var temp;

    for(var i=0;i
        temp='''' + field.value.substring(i,i+1)

        if(valid.indexOf(temp)==''-1'') {
                ok=''no'';
        }
    }

    if(ok==''no'') {
        alert(''error'');
        field.focus();
    }
}
Ans  : It will force a user to enter only English alphabet character values.

Ques : How can created cookies be deleted using JavaScript?
Ans  : Overwrite with an expiry date in the past

Ques : What would be the value of 'ind' after execution of the following code?

var msg="Welcome to ExpertRating"
var ind= msg.substr(3, 3)
Ans  : com

Ques : Are the two statements below interchangeable?

object.property
object[''property'']
Ans  :  Yes

Ques :  Which of the following is not a valid method in generator-iterator objects in JavaScript?
Ans  : stop()

Ques : Which of the following code snippets will return all HTTP headers?
Ans  : var req = new XMLHttpRequest(); req.open('GET', document.location, false); req.send(null); var headers = req.getAllResponseHeaders().toLowerCase(); alert(headers);

Ques :  Which of the following is the most secure and efficient way of declaring an array?
Ans  :  var a = []

Ques : Which of the following built-in functions is used to access form elements using their IDs?
Ans  :  getElementById(id)

Ques : Which of the following correctly uses a timer with a function named rearrange()?
Ans  : tmr=setTimeout("rearrange ()",1)

Ques : Which of the following can be used to escape the ' character?
Ans  :  \

Ques : Which event can be used to validate the value in a field as soon as the user moves out of the field by pressing the tab key?
Ans  : onblur

Ques : When setting cookies with JavaScript, what will happen to the cookies.txt data if the file exceeds the maximum size?
Ans  : The file is truncated to the maximum length.

Ques : Which of the following are not global methods and properties in E4X?
Ans  :  setName() and setNamespace()

Ques : What is the purpose of while(1) in the following JSON response?

while(1);[['u',[['smsSentFlag','false'],['hideInvitations','false'],['remindOnRespondedEventsOnly','true'],['hideInvitations_remindOnRespondedEventsOnly','false_true'],['Calendar ID stripped for privacy','false'],['smsVerifiedFlag','true']]]]
Ans  : It makes it difficult for a third-party to insert the JSON response into an HTML document with a script tag.
Ques : Consider the three variables:

someText = 'JavaScript1.2';
pattern = /(\w+)(\d)\.(\d)/i;
outCome = pattern.exec(someText);

What does outCome[0] contain?
Ans  :  JavaScript1.2

Ques : Which of the following determines whether cookies are enabled in a browser or not?
Ans  : (navigator.cookieEnabled)? true : false

Ques : How can global variables be declared in JavaScript?
Ans  :  Declare the variable between the 'script' tags, and outside a function to make the variable global

Ques : What will be output of the following code?

function testGenerator() {
    yield "first";
    document.write("step1");

    yield "second";
    document.write("step2");

    yield "third";
    document.write("step3");
}

var g = testGenerator();
document.write(g.next());
document.write(g.next());
Ans  : firststep1second

Ques : Which of the following methods will copy data to the Clipboard?
Ans  : execCommand('Copy')

Ques : Which of the following code snippets trims whitespace from the beginning and end of the given string str?
Ans  : str.replace(/^\s+|\s+$/g, '');

Ques : What is the meaning of obfuscation in JavaScript?
Ans  : Making code unreadable using advanced algorithms.

Ques : Which of the following JavaScript Regular Expression modifiers finds one or more occurrences of a specific character in a string?
Ans  : +

Ques : Which of the following is not a valid JavaScript operator?
Ans  :  ^    

Ques : Which of the following can be used to invoke an iframe from a parent page?
Ans  :  window.frames

Ques : What value would JavaScript assign to an uninitialized variable?
Ans  : undefined

Ques : How can the user's previously navigated page be determined using JavaScript?
Ans  :  Using the window object

Ques : Which of the following is not a valid method for looping an array?
Ans  :  var a= [1,2]; a.loop( function(item) { alert(item); })

Ques : Which of the following correctly sets a class for an element?
Ans  :  document.getElementById(elementId).setAttribute("className", "Someclass");

Ques : An HTML form contains 10 checkboxes all named "chkItems". Which JavaScript function can be used for checking all the checkboxes together?
Ans  : function CheckAll() { for (z = 0; z < document.forms[0].chkItems.length; z++) { document.forms[0].chkItems[z].checked=true } }

Thanks for watching this test Question & Answers. Please don't forget to leave a comment about this post. You can also find some more effective test question & answers, information, techtunes, technology news, tutorials, online earning information, recent news, results, job news, job exam results, admission details & another related services on the following sites below. Happy Working!
News For Todays ARSBD oEtab ARSBD-JOBS DesignerTab