Wednesday 27 April 2011

JavaScript & AJAX interview questions(50)

1.  Why so JavaScript and Java have similar name?
A.  JavaScript is a stripped-down version of Java
B.  JavaScript's syntax is loosely based on Java's
C.  They both originated on the island of Java
D.  None of the above

2.  When a user views a page containing a JavaScript program, which machine actually executes the script?
A.  The User's machine running a Web browser
B.   The Web server
C.  A central machine deep within Netscape's corporate offices
D.  None of the above

3.  ______ JavaScript is also called client-side JavaScript.
A.  Microsoft
B.  Navigator
C.  LiveWire
D.  Native

4.  __________ JavaScript is also called server-side JavaScript.
A.  Microsoft
B.   Navigator
C.  LiveWire
D.  Native

5.  What are variables used for in JavaScript Programs?
A.  Storing numbers, dates, or other values
B.   Varying randomly
C.  Causing high-school algebra flashbacks
D.  None of the above

6.  _____ JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation.
A.  Client-side
B.   Server-side
C.  Local
D.  Native

7.  What should appear at the very end of your JavaScript?
The <script LANGUAGE="JavaScript">tag
A.   The </script>
B.    The <script>
C.  The END statement
D.  None of the above



8.  Which of the following can't be done with client-side JavaScript?
A.  Validating a form
B.   Sending a form's contents by email
C.  Storing the form's contents to a database file on the server
D.  None of the above

9.  Which of the following are capabilities of functions in JavaScript?
A.  Return a value
B.   Accept parameters and Return a value
C.  Accept parameters
D.  None of the above

10.  Which of the following is not a valid JavaScript variable name?
A.  2names
B.   _first_and_last_names
C.  FirstAndLast
D.  None of the above

11.  ______ tag is an extension to HTML that can enclose any number of JavaScript statements.
A.  <SCRIPT>
B.   <BODY>
C.  <HEAD>
D.  <TITLE>

12.  How does JavaScript store dates in a date object?
A.  The number of milliseconds since January 1st, 1970
B.   The number of days since January 1st, 1900
C.  The number of seconds since Netscape's public stock offering.
D.  None of the above

13.  Which of the following attribute can hold the JavaScript version?
A.  LANGUAGE
B.   SCRIPT
C.  VERSION
D.  None of the above

14.  What is the correct JavaScript syntax to write "Hello World"?
A.  System.out.println("Hello World")
B.   println ("Hello World")
C.  document.write("Hello World")
D.  response.write("Hello World")

15.  Which of the following way can be used to indicate the LANGUAGE attribute?
A.  <LANGUAGE="JavaScriptVersion">
B.   <SCRIPT LANGUAGE="JavaScriptVersion">
C.  <SCRIPT LANGUAGE="JavaScriptVersion">    JavaScript statements…</SCRIPT>
D.  <SCRIPT LANGUAGE="JavaScriptVersion"!>    JavaScript statements…</SCRIPT>

16.  Inside which HTML element do we put the JavaScript?
A.  <js>
B.   <scripting>
C.  <script>
D.  <javascript>

17.  What is the correct syntax for referring to an external script called " abc.js"?
A.  <script href=" abc.js">
B.   <script name=" abc.js">
C.  <script src=" abc.js">
D.  None of the above

18.  Which types of image maps can be used with JavaScript?
A.  Server-side image maps
B.  Client-side image maps
C.  Server-side image maps and Client-side image maps
D.  None of the above

19.  Which of the following navigator object properties is the same in both   Netscape and IE?
A.  navigator.appCodeName
B.   navigator.appName
C.  navigator.appVersion
D.  None of the above

20.  Which is the correct way to write a JavaScript array?
A.  var txt = new Array(1:"tim",2:"kim",3:"jim")
B.   var txt = new Array:1=("tim")2=("kim")3=("jim")
C.  var txt = new Array("tim","kim","jim")
D.  var txt = new Array="tim","kim","jim"

21.  What does the <noscript> tag do?
A.  Enclose text to be displayed by non-JavaScript browsers.
B.   Prevents scripts on the page from executing.
C.  Describes certain low-budget movies.
D.  None of the above

22. If para1 is the DOM object for a paragraph, what is the correct syntax to change the text within the paragraph?
A.  "New Text"?
B.  para1.value="New Text";
C.  para1.firstChild.nodeValue= "New Text";
D.  para1.nodeValue="New Text";

23.  JavaScript entities start with _______ and end with _________.
A.  Semicolon, colon
B.   Semicolon, Ampersand
C.  Ampersand, colon
D.  Ampersand, semicolon

24.  Which of the following best describes JavaScript?
A.  a low-level programming language.
B.   a scripting language precompiled in the browser.
C.  a compiled scripting language.
D.  an object-oriented scripting language.

25.  Choose the server-side JavaScript object?
A.  FileUpLoad
B.   Function
C.  File
D.  Date

26.  Choose the client-side JavaScript object?
A.  Database
B.   Cursor
C.  Client
D.  FileUpLoad

27.  Which of the following is not considered a JavaScript operator?
A.  new
B.  this
C.  delete
D.  typeof

28.  ______method evaluates a string of JavaScript code in the context of the specified object.
A.  Eval
B.   ParseInt
C.  ParseFloat
D.  Efloat

29.  Which of the following event fires when the form element loses the focus: <button>, <input>, <label>, <select>, <textarea>?
A.  onfocus
B.  onblur
C.  onclick
D.  ondblclick

30.  The syntax of Eval is ________________
A.  [objectName.]eval(numeric)
B.  [objectName.]eval(string)
C.  [EvalName.]eval(string)
D.  [EvalName.]eval(numeric)

31.  JavaScript is interpreted by _________
A.  Client
B.   Server
C.  Object
D.  None of the above

32.  Using _______ statement is how you test for a specific condition.
A.  Select
B.  If
C.  Switch
D.  For

33.  Which of the following is the structure of an if statement?
A.  if (conditional expression is true) thenexecute this codeend if
B.   if (conditional expression is true)execute this codeend if
C.  if (conditional expression is true)   {then execute this code>->}
D.  if (conditional expression is true) then {execute this code}

34.  How to create a Date object in JavaScript?
A.  dateObjectName = new Date([parameters])
B.   dateObjectName.new Date([parameters])
C.  dateObjectName := new Date([parameters])
D.  dateObjectName Date([parameters])

35.  The _______ method of an Array object adds and/or removes elements from an array.
A.  Reverse
B.   Shift
C.  Slice
D.  Splice

36.  To set up the window to capture all Click events, we use which of the following statement?
A.  window.captureEvents(Event.CLICK);
B.   window.handleEvents (Event.CLICK);
C.  window.routeEvents(Event.CLICK );
D.  window.raiseEvents(Event.CLICK );

37.  Which tag(s) can handle mouse events in Netscape?
A.  <IMG>
B.  <A>
C.  <BR>
D.  None of the above

38.  ____________ is the tainted property of a window object.
A.  Pathname
B.   Protocol
C.  Defaultstatus
D.  Host

39.  To enable data tainting, the end user sets the _________ environment variable.
A.  ENABLE_TAINT
B.   MS_ENABLE_TAINT
C.  NS_ENABLE_TAINT
D.  ENABLE_TAINT_NS

40.  In JavaScript, _________ is an object of the target language data type that encloses an object of the source language.
A.  a wrapper
B.   a link
C.  a cursor
D.  a form



41.  When a JavaScript object is sent to Java, the runtime engine creates a Java wrapper of type ___________
A.  ScriptObject
B.  JSObject
C.  JavaObject
D.  Jobject

42.  _______ class provides an interface for invoking JavaScript methods and examining JavaScript properties.
A.  ScriptObject
B.  JSObject
C.  JavaObject
D.  Jobject

43.  _________ is a wrapped Java array, accessed from within JavaScript code.
A.  JavaArray
B.   JavaClass
C.  JavaObject
D.  JavaPackage
               
44. A ________ object is a reference to one of the classes in a Java package, such as netscape.javascript .
A.  JavaArray
B.  JavaClass
C.  JavaObject
D.  JavaPackage

45.  The JavaScript exception is available to the Java code as an instance of __________
A.  netscape.javascript.JSObject
B.  netscape.javascript.JSException
C.  netscape.plugin.JSException
D.  None of the above

46. To automatically open the console when a JavaScript error occurs which of the following is added to prefs.js?
A.  user_pref(" javascript.console.open_on_error", false);
B.   user_pref("javascript.console.open_error ", true);
C.  user_pref("javascript.console.open_error ", false);
D.   user_pref("javascript.console.open_on_error", true);

47.  To open a dialog box each time an error occurs, which of the following is added to prefs.js?
A.  user_pref("javascript.classic.error_alerts", true);
B.   user_pref("javascript.classic.error_alerts ", false);
C.  user_pref("javascript.console.open_on_error ", true);
D.  user_pref("javascript.console.open_on_error ", false);

48.  The syntax of a blur method in a button object is ______________
A.  Blur()
B.   Blur(contrast)
C.  Blur(value)
D.  Blur(depth)

49.  The syntax of capture events method for document object is ______________
A.  captureEvents()
B.   captureEvents(args eventType)
C.  captureEvents(eventType)
D.  captureEvents(eventVal)

50.  The syntax of close method for document object is ______________
A.  Close(doc)
B.   Close(object)
C.  Close(val)
D.  Close()

Sunday 17 April 2011

JavaScript interview questions and answers

  1. What’s relationship between JavaScript and ECMAScript? - ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.
  2. What are JavaScript types? - Number, String, Boolean, Function, Object, Null, Undefined.
  3. How do you convert numbers between different bases in JavaScript? - Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);
  4. What does isNaN function do? - Return true if the argument is not a number.
  5. What is negative infinity? - It’s a number in JavaScript, derived by dividing negative number by zero.
  6. What boolean operators does JavaScript support? - &&, || and !
  7. What does "1"+2+4 evaluate to? - Since 1 is a string, everything is a string, so the result is 124.
  8. How about 2+5+"8"? - Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result.
  9. What looping structures are there in JavaScript? - for, while, do-while loops, but no foreach.
  10. How do you create a new object in JavaScript? - var obj = new Object(); or var obj = {};
  11. How do you assign object properties? - obj["age"] = 17 or obj.age = 17.
  12. What’s a way to append a value to an array? - arr[arr.length] = value;
  13. What is this keyword? - It refers to the current object.

Java threads question set

  1. Do I need to use synchronized on setValue(int)? - It depends whether the method affects method local variables, class static or instance variables. If only method local variables are changed, the value is said to be confined by the method and is not prone to threading issues.
  2. Do I need to use synchronized on setValue(int)? - It depends whether the method affects method local variables, class static or instance variables. If only method local variables are changed, the value is said to be confined by the method and is not prone to threading issues.
  3. What is the SwingUtilities.invokeLater(Runnable) method for? - The static utility method invokeLater(Runnable) is intended to execute a new runnable thread from a Swing application without disturbing the normal sequence of event dispatching from the Graphical User Interface (GUI). The method places the runnable object in the queue of Abstract Windowing Toolkit (AWT) events that are due to be processed and returns immediately. The runnable object’s run() method is only called when it reaches the front of the queue. The deferred effect of the invokeLater(Runnable) method ensures that any necessary updates to the user interface can occur immediately, and the runnable work will begin as soon as those high priority events are dealt with. The invoke later method might be used to start work in response to a button click that also requires a significant change to the user interface, perhaps to restrict other activities, while the runnable thread executes.
  4. What is the volatile modifier for? - The volatile modifier is used to identify variables whose values should not be optimized by the Java Virtual Machine, by caching the value for example. The volatile modifier is typically used for variables that may be accessed or modified by numerous independent threads and signifies that the value may change without synchronization.
  5. Which class is the wait() method defined in? - The wait() method is defined in the Object class, which is the ultimate superclass of all others. So the Thread class and any Runnable implementation inherit this method from Object. The wait() method is normally called on an object in a multi-threaded program to allow other threads to run. The method should should only be called by a thread that has ownership of the object’s monitor, which usually means it is in a synchronized method or statement block.
  6. Which class is the wait() method defined in? I get incompatible return type for my thread’s getState( ) method! - It sounds like your application was built for a Java software development kit before Java 1.5. The Java API Thread class method getState() was introduced in version 1.5. Your thread method has the same name but different return type. The compiler assumes your application code is attempting to override the API method with a different return type, which is not allowed, hence the compilation error.
  7. What is a working thread? - A working thread, more commonly known as a worker thread is the key part of a design pattern that allocates one thread to execute one task. When the task is complete, the thread may return to a thread pool for later use. In this scheme a thread may execute arbitrary tasks, which are passed in the form of a Runnable method argument, typically execute(Runnable). The runnable tasks are usually stored in a queue until a thread host is available to run them. The worker thread design pattern is usually used to handle many concurrent tasks where it is not important which finishes first and no single task needs to be coordinated with another. The task queue controls how many threads run concurrently to improve the overall performance of the system. However, a worker thread framework requires relatively complex programming to set up, so should not be used where simpler threading techniques can achieve similar results.
  8. What is a green thread? - A green thread refers to a mode of operation for the Java Virtual Machine (JVM) in which all code is executed in a single operating system thread. If the Java program has any concurrent threads, the JVM manages multi-threading internally rather than using other operating system threads. There is a significant processing overhead for the JVM to keep track of thread states and swap between them, so green thread mode has been deprecated and removed from more recent Java implementations. Current JVM implementations make more efficient use of native operating system threads.
  9. What are native operating system threads? - Native operating system threads are those provided by the computer operating system that plays host to a Java application, be it Windows, Mac or GNU/Linux. Operating system threads enable computers to run many programs simultaneously on the same central processing unit (CPU) without clashing over the use of system resources or spending lots of time running one program at the expense of another. Operating system thread management is usually optimised to specific microprocessor architecture and features so that it operates much faster than Java green thread processing

C questions for a hardware engineer

  1. What are the total number of lines written in C/C++? What is the most complicated/valuable program written in C/C++?
  2. What compiler was used?
  3. Have you studied buses? What types?
  4. Have you studied pipelining? List the 5 stages of a 5 stage pipeline. Assuming 1 clock per stage, what is the latency of an instruction in a 5 stage machine? What is the throughput of this machine ?
  5. How many bit combinations are there in a byte?
  6. What is the difference between = and == in C?
  7. Are you familiar with VHDL and/or Verilog?

Friday 1 April 2011

Embedded firmware interview questions

  • Write function in C that gets array of chars, and search for the longest sequence of repeatedly 1 bits. It returns the the first bit place in the sequence and the number of 1 bits in the sequence. - (a) loop of 2^0, 2^1, … , 2^7 is done with 1<<j when 0<=j<=7. (b) Take care of remembering the first place of the bit sequence you are counting.
  • You have 16bit register that increment itself and loops about every second. When the register reach 0xffff it will issue an interupt and will run the function update_time(). There is a function unsigned long get_time() that returns the time. You need to implement the two functions. - (a) You need to count every interrupt in order to save the number of seconds. (b) The counter will be the 16bit MSB, and the actual register will be 16bit LSB. (c) If the register will be at ~0xfff0, you will return MSB that is not correct, because you will read the counter, then interrupt will accure and increment by one. Now you have counter that is not correct. (d) You need to check for the (c) problem, and if you catch the problem, you need to read once again the register and the counter before you return them. You depend on the fact the you have about another second until the register will loop.

Search here for "Freshers Jobs"