Tampilkan postingan dengan label i. Tampilkan semua postingan
Tampilkan postingan dengan label i. Tampilkan semua postingan

I cant belive I found this in a CAD file!

Rabu, 26 Maret 2014

While working on a file today I came across a bit of text that must have been pasted into the file by accident:






It seems that somebody was watching HULU at work one day, found the link to an episode of "Greys Anatomy" and pasted it into this DWG file instead of their browser!  OOPS!!!  I guess they just got busted for goofing off at work!
Read More..

The pre Java Interview online written test questions that I hate

Minggu, 23 Februari 2014

Some online assessment sites basically try to test your memorizing capabilities with API based questions listed below. Also, about 30% - 50% of the questions are on API that you rarely use or obsolete. When you have the API documentation, why remember the API. Here are a few such questions I came across recently. If you want to ask such questions, then allow people to refer to the online API documentation. These tests are only going to filter out quality candidates.


Q. Which of the following are valid JavaMail message types?

a) Message.RecipientType.CC
b) MessageRecipientType.CC
c) Message.RecipientType.CCList
d) Message.RecipientType.BCC
e) MessageRecipientType.BCC

A. a and d


Q. Which of the following are JNDI event listeners?

a) NamespaceChangeListener
b) ObjectListener
c) ObjectChangeListener
d) UnsolicitedNotificationListener
e) ObjectNotFoundListenr

A. a, c, and d.


Q. Which of the following statements are correct, based on the following code snippet for uploading a file?

<form action="upload"  enctype="multipart/form-data">
<input type="text" name="description" />
<input type="file" name="file" />
<input type="submit" />
</form>


a) The enctype must be "text/form-data"
b) The method attribute is missing in the "form" element and it should be of type "GET"
c) The method attribute is missing in the "form" element and it should be of type "POST"
d) The "input" element must have the attribute "value"
e) The above syntax is correct

A. c. 

The correct format is:

<form action="upload"  method="post" enctype="multipart/form-data">
<input type="text" name="description" />
<input type="file" name="file" />
<input type="submit" />
</form>


Q. Which of the following objects are NOT part of the JavaBean Activation Framework (JAF)?

a) DataSource
b) DataFileHandler
c) DataHandler
d) DataContentHandler
e) FileDateHandler
f) FileTypeMap

A. b and e. All the others are part of JAF.


Q. Which of the following statements are INCORRECT?

a) HttpServletRequest.getRemoteUser( ) return null;
b) HttpServletRequest.isUserInRole(java.lang.String role) throws SecurityException ;
c) HttpServletRequest.getRemoteUser( ) return false;
d) HttpServletRequest.isUserInRole(java.lang.String role) return false;
e) HttpServletRequest.getUserPrincipal( ) throws SecurityException
f) HttpServletRequest.getUserPrincipal( ) return null;


A. b, c, and e are INCORRECT.

Q. Which of the following elements would you see in a SOAP payload with attachments?

a) <soap:header>
b) <soap:footer>
c) <soap:body>
d) <soap:content>
e) <soap:attachment>

A. a and c.


Q. Which of the following can be used in place of "****" in the code snippet shown below?


if(request.getParameter("location").equals("nextPage") {

      *****

}


a) request.sendRedirect("url");
b) response.sendRedirect("url");
c) request.redirect("url");
d) response.redirect("url");
e) response.send("url")


A.b

Q. Which of the following are valid JDBC  result set types?


a) TYPE_FORWARD_ONLY
b) TYPE_BACKWARD_ONLY
c) TYPE_SCROLL_INSENSITIVE
d) TYPE_SCROLL_SENSITIVE
e) TYPE_SCROLL_REVERSE

A. a, c, and d.


Q. Which of the following are valid JSP life cycle methods?

a) jspService( )
b)_jspService( )
c) jspInit( )
d) jspDestroy( )
e) _jspInit()

A. a, c, and d.


Q. Which of the following are CORRECT about JCA?

a)  JCA is a standard architecture for integrating heterogeneous EIS systems not written in Java
b)  JCA is a standard architecture for integrating other JEE systems
c)  JCA can be used to integrate with mainframe systems
d)  JCA can be used to integrate with ERP systems
e)  JCA can be used to integrate with Database systems
f)  The underlying EIS systems are integrated using pluggable resource adapters

A. a, c, d, e and f.

Q. Which of the following are INCORRECT about JAAS?

a) JAAS bring in location based authentication and authorization to JEE.
b) JAAS is designed to bring subject based authentication and authorization to JEE
c) JAAS is modeled after the Pluggable Authentication Module (PAM)-a popular API for defining authentication modules in a portable and extensible manner
d) JAAS can be used across managed resources such as servlet/JSP, EJB, or MBeans and over a variety of connection protocols such as HTTP, RMI/IIOP, or JMX/RMI.
e) JAAS was fully integrated into the core Java security architecture

A. a.

The last 2 questions are not bad, but for most of the other questions, the answers can be found by jumping on a search engine for 5 to 15 minutes. It is not really testing your understanding of the core concepts or hands-on experience.

Is it just me, or do you agree with me? Please post the Java Interview Questions that you hate.

Read More..

Java new I O Interview Questions and Answers

Jumat, 07 Februari 2014



The Java New IO is very powerful and it is all about performance!, performance!!, and performance!!!. But, you need to get your head around how the buffers work. Here are some questions and answers that will help you do that. Q. How does the Java NIO (i.e New IO) introduced in Java version 1.4 differ from the old IO?
A. The NIO is all about better performance.

IONIO (New IO)
Stream oriented. This means that you read one or more bytes at a time, from a stream. What you do with the read bytes is up to you. They are not cached anywhere. Furthermore, you cannot move forward and back in the data in a stream. If you need to move forward and back in the data read from a stream, you will need to buffer yourself first.

Buffer oriented. This means better performance. Data is read into a buffer from which it be processed later. You can move forward and back in the buffer. This gives you a bit more flexibility during processing. However, you also need to check if the buffer contains all the data you need in order to fully process it.
Blocking IO. This means when a thread invokes a read() or write(), that thread is blocked until there is some data to read, or the data is fully written. The thread can do nothing else in the meantime.

Non blocking IO. This means better performance. NIOs non-blocking mode enables a thread to request reading data from a channel, and only get what is currently available, or do nothing at all, if no data is currently available. Rather than remain blocked until data becomes available for reading, the thread can proceed with doing something else.
You need to create additional threads to read and write data in parallel. More threads means more CPU context switching and consuming more thread stacks.Selectors.  This also means better performance. NIOs selectors allow a single thread to monitor multiple channels of input. You can register multiple channels with a selector, then use a single thread to "select" the channels that have input available for processing, or select the channels that are ready for writing. This selector mechanism makes it easy for a single thread to manage multiple channels. This is also known as multiplexing. The Apache MINA package is based on Java NIO to write high performance networking applications. For example, a TCP server.

Here is the diagrammatic overview:



Q. How do you manipulate the buffer in NIO?
A. The NIO buffer  has following 3 state variables -- position, limit, and capacity

  • position: The position value keeps track of how much you have gotten from the buffer. It specifies from which array element the next byte will come. Thus, if youve written 1 bytes as shown below with shaded area to a channel from a buffer, that buffers position will be set to 1 (starting from 0), referring to the second element of the array as shown in the diagram.
  • limit: The limit variable specifies how much room there is left to put data into -- in the case of reading from a channel into a buffer or how much data there is left to get -- in the case of writing from a buffer into a channel. The position is always less than, or equal to, the limit. The limit is 3 (counting from 0) in the diagram below.
  • capacity:  The capacity of a buffer specifies the maximum amount of data that can be stored in the underlying array. The limit can never be larger than the capacity. The capacity is 6 (counting from 0) in the diagram below.

In the above diagram, the position starts with 0, and after reading 1 byte, it becomes 1 byte, and the limit value of 3 states that there are 2 more bytes to be read. 



Q. What do you understand by terms flip( ) and clear( ) in NIO?
A.

Flip

When you are ready to write your data to an output channel. You must call the flip() method. This method does two key things:

1. It sets the limit to the current position.
2. It sets the position to 0.

You are now ready to begin writing data to a channel from the buffer starting from 0 to the limit.


Clear

After you have done your writes, the final step is to call the buffers clear() method. This method resets the buffer in preparation for receiving more bytes. Clear does two key things:

1. It sets the limit to match the capacity.
2. It sets the position to 0.


Also, the get and put methods are used to get and put data to and from the buffer respectively. some coding examples are discussed in Java I/O interview Questions and Answers.


Q. What is in the NIO.2 package introduced in Java 7?
A. The more New I/O APIs for the Java Platform (NIO.2) in Java 7 enhance the New I/O APIs (NIO) introduced in Java 1.4 by adding

  • The four asynchronous channels to the java.nio.channels package. 
  •  The java.io.File class is upgraded to the java.nio.file.Path that allows logical manipulating of paths in memory without accessing the file system.
  • The NIO.2 associates the notion of metadata like is hidden, is it a directory, size, access control, etc with attributes and provides access to them through the java.nio.file.attribute package. Since different file systems have different notions about which attributes should be tracked, NIO.2 groups the attributes into views, each of which maps to a particular file system implementation.
  • The NIO.2 provides support for both hard links and symbolic links and the Path class knows how to detect a link and will behave in the default manner if no configuration of behavior is specified.
  • The NIO.2 comes with a set of brand new methods for managing files and directories, such as create, read, write, move, delete, and so on. The most of these tasks are found in the java.nio.file.Files class.
  • The FileVisitor interface introduced in Java 7 makes recursing through directories and files a breeze.
  • The Watch Service API was introduced in Java 7 (NIO.2) as a thread-safe service that is capable of watching  a directory for changes to its content through actions such as create, delete, and modify. This means, with NIO.2, you no longer need to poll the file system for changes or use other in-house solutions to monitor the file system changes.
  • Java 7 (NIO.2) introduces a new interface for working with Random Access Files with its SeekableByteChannel and an interface named NetworkChannel that provides network channel classes for tetworking.
Read More..