Thursday, December 16, 2010

Computer Network Questions and Answers

1. Why is it important for protocols configured on top of the Ethernet to have a length field in their header, indicating how long the message is?
Ans: It is important to indicate the message size because of the following reasons:
 There can be padded data inside the message,
 In case of collision only part of data is received, so it can checked by the message length field, otherwise, it won't be known.
 The Ethernet frame size isn't fixed. It can hold up to 1500 bytes but it can vary from network to network.

2. What kinds of problems can arise when two hosts on the same Ethernet share the same hardware address? Describe what happens and why that behavior is a problem.
Ans : 1. Hosts are using hardware address to filter whether the packet is for them or not. So, they can discard the packets which do not belong to them. However, if the same hardware address is shared with other host, it is likely to receive wrong packets which can harm the host.
2. On the same Ethernet line, hosts keep dynamic ARP table to match Internet address and physical address (MAC address), but if they see two different IP addresses having same MAC address. It is hard to tell what happens for this.
3. If hosts share the switch on the Ethernet line, the switch will get confused to update the address table. It will continuously change the address table, so it can lead to unstable state.

3. The 1982 Ethernet specification allowed between any two stations up to 1500 m of coaxial cable, 1000 m of other point-to-point link cable, and two repeaters. Each station or repeater connects to the coaxial cable via up to 50 m of “drop cable.” Typical delays associated with each device are given in Table below (where c = speed of light in a vacuum = 3×108 m/s). What is the worst-case round-trip propagation delay, measured in bits, due to the sources listed? (This list is not complete; other sources of delay include sense time and signal rise time.)

Item Delay
Coaxial cable propagation speed .77c
Link/drop cable propagation speed .65c
Repeaters approximately 0.6 μs each
Transceivers approximately 0.2 μs each
Typical delays associated with various devices
One-way delays:
Coax: 1500m 6.49 3 s
link: 1000m 5.13 3 s
repeaters two 1.20 3 s
transceivers six (two for 1.20 3 s
each repeater,
one for each
station)

drop cable 6 , 50m 1.54 3 s
Total: 15.56 3 s
The roundtrip delay is thus about 31.1 3 s, or 311 bits. The “official” total is 464 bits, which when extended by 48 bits of jam signal exactly accounts for the 512-bit minimum packet size.
The 1982 Digital-Intel-Xerox specification presents a delay budget (page 62 of that document) that totals 463.8 bit-times, leaving 20 nanoseconds for unforeseen contingencies.

4. Coaxial cable Ethernet was limited to a maximum of 500 m between repeaters, which regenerate the signal to 100% of its original amplitude. Along one 500-m segment, the signal could decay to no less than 14% of its original value (8.5 dB). Along 1500 m, then, the decay might be (0.14)3 = 0.3%. Such a signal, even along 2500 m, is still strong enough to be read; why then are repeaters required every 500 m?
Ans>>A station must not only detect a remote signal, but for collision detection it must detect a remote signal while it itself is transmitting. This requires much higher remote-signal intensity.

5. Suppose the round-trip propagation delay for Ethernet is 46.4 μs. This yields a minimum packet size of 512 bits (464 bits corresponding to propagation delay + 48 bits of jam signal).
(a) What happens to the minimum packet size if the delay time is held constant, and the signaling rate rises to 100 Mbps?
(b) What are the drawbacks to so large a minimum packet size?
(c) If compatibility were not an issue, how might the specifications be written so as to permit a smaller minimum packet size?

Ans>>(a) Assuming 48 bits of jam signal was still used, the minimum packet size would be 4640+48 bits = 586 bytes.
(b) This packet size is considerably larger than many higher-level packet sizes, resulting in considerable wasted bandwidth.
(c) The minimum packet size could be smaller if maximum collision domain diameter were reduced, and if sundry other tolerances were tightened up.

6. A group of N stations share a 56-kbps pure ALOHA channel. Each station outputs a 1000-bit frame on an average of once every 100 sec, even if the previous one has not yet been sent (e.g., the stations can buffer outgoing frames). What is the maximum value of N?
ANS>>with pure ALOHA the usable bandwidth is 0.184 × 56 kbps = 10.3 kbps.Each station requires 10 bps, so N = 10300/10 = 1030 stations

7. Consider the delay of pure ALOHA versus slotted ALOHA at low load. Which one is less? Explain your answer.
ANS>>With pure ALOHA, transmission can start instantly. At low load, no collisions are expected so the transmission is likely to be successful. With slotted ALOHA, it has to wait for the next slot. This introduces half a slot time of delay.

8. Ten thousand airline reservation stations are competing for the use of a single slotted ALOHA channel. The average station makes 18 requests/hour. A slot is 125 μsec. What is the approximate total channel load?
ANS>>Each terminal makes one request every 200 sec, for a total load of 50 requests/sec. Hence G = 50/8000 = 1/160.

9. A large population of ALOHA users manages to generate 50 requests/sec, including both originals and retransmissions. Time is slotted in units of 40 msec.
a. What is the chance of success on the first attempt?
b. What is the probability of exactly k collisions and then a success?
c. What is the expected number of transmission attempts needed?

ANS>> (a) With G = 2 the Poisson law gives a probability of e −2.
(b) (1 − e −G)ke −G = 0.135 × 0.865k .
(c) The expected number of transmissions is eG = 7.4.

10. Measurements of a slotted ALOHA channel with an infinite number of users show that 10 percent of the slots are idle.
a. What is the channel load, G?
b. What is the throughput?
c. Is the channel underloaded or overloaded?

ANS>> (a) From the Poisson law again, P0 = e −G, so G = −lnP0 = −ln 0.1 = 2.3.
(b) Using S = Ge−G with G = 2.3 and e −G = 0.1, S = 0.23.
(c) Whenever G > 1 the channel is overloaded, so it is overloaded.

11. In an infinite-population slotted ALOHA system, the mean number of slots a station waits between a collision and its retransmission is 4. Plot the delay versus throughput curve for this system.
ANS>>The number of transmissions is E = eG. The E events are separated by E – 1 intervals of four slots each, so the delay is 4(eG − 1). The throughput is given by S = Ge−G. Thus, we have two parametric equations, one for delay and one for throughput, both in terms of G. For each G value it is possible to find the corresponding delay and throughput, yielding one point on the curve.

12. 1-km-long, 10-Mbps CSMA/CD LAN (not 802.3) has a propagation speed of 200 m/μsec. Repeaters are not allowed in this system. Data frames are 256 bits long, including 32 bits of header, checksum, and other overhead. The first bit slot after a successful transmission is reserved for the receiver to capture the channel in order to send a 32-bit acknowledgement frame. What is the effective data rate, excluding overhead, assuming that there are no collisions?
ANS>> The round-trip propagation time of the cable is 10µsec. A complete transmission has six phases: transmitter seizes cable (10µsec) transmit data (25.6µsec) Delay for last bit to get to the end (5.0 µsec) receiver seizes cable (10µsec) acknowledgement sent (3.2 µsec) Delay for last bit to get to the end (5.0 µsec) the sum of these is 58.8 µsec. In this period, 224 data bits are sent, for a rate of about 3.8 Mbps.

13. Consider building a CSMA/CD network running at 1 Gbps over a 1-km cable with no repeaters. The signal speed in the cable is 200,000 km/sec. What is the minimum frame size?
ANS>> For a 1-km cable, the one-way propagation time is 5 μsec, so 2τ = 10 μsec. To make CSMA/CD work, it must be impossible to transmit an entire frame in this interval. At 1 Gbps, all frames shorter than 10,000 bits can be completely transmitted in under 10 μsec, so the minimum frame is 10,000 bits or 1250 bytes.

14. An IP packet to be transmitted by Ethernet is 60 bytes long, including all its headers. If LLC is not in use, is padding needed in the Ethernet frame, and if so, how many bytes?
ANS>>The minimum Ethernet frame is 64 bytes, including both addresses in the Ethernet frame header, the type/length field, and the checksum. Since the header fields occupy 18 bytes and the packet is 60 bytes, the total frame size is 78 bytes, which exceeds the 64-byte minimum. Therefore, no padding is used.

15. Ethernet frames must be at least 64 bytes long to ensure that the transmitter is still going in the event of a collision at the far end of the cable. Fast Ethernet has the same 64-byte minimum frame size but can get the bits out ten times faster. How is it possible to maintain the same minimum frame size?
ANS>>The maximum wire length in fast Ethernet is 1/10 as long as in Ethernet.

16. Some books quote the maximum size of an Ethernet frame as 1518 bytes instead of 1500 bytes. Are they wrong? Explain your answer.
ANS>>The payload is 1500 bytes, but when the destination address, source address, type/length, and checksum fields are counted too, the total is indeed 1518.

17. Recall that with the CSMA/CD protocol, the adapter waits K*512 bit times after a collision, where K is drawn randomly. For K=100, how long does the adapter wait until returning to Step 2 for a 10 Mbps Ethernet? For a 100 Mbps Ethernet?
ANS>> Wait for 51,200 bit times. For 10 Mbps, this wait is

For 100 Mbps, the wait is 512 μ sec.

18. Suppose nodes A and B are on the same 10 Mbps Ethernet segment, and the propagation delay between the two nodes is 225 bit times. Suppose node A begins transmitting a frame, and before it finishes station B begins transmitting a frame. Can A finish transmitting before it detects that B has transmitted? Why or why not? If the answer is yes, then A incorrectly believes that its frame was successfully transmitted without a collision.
Hint: Suppose at time t=0 bit times, A begins transmitting a frame. In the worst case, A transmits a minimum size frame of 512+64(prembale) bit times. So A would finish transmitting the frame at t=512+64 bit times. Thus the answer is no if B's signal reaches A before bit time t=512+64 bits. In the worst case, when does B's signal reach A?

ANS>> At t = 0 A transmits. At t = 576 , A would finish transmitting. In the worst case, B begins transmitting at time t = 224 . At time t = 224 + 225 = 449 B 's first bit arrives at A . Because 449 < 576 , A aborts before completing the transmission of the packet, as it is supposed to do. Thus A cannot finish transmitting before it detects that B transmitted. This implies that if A does not detect the presence of a host, then no other host begins transmitting while A is transmitting. 19. Suppose nodes A and B are on the same 10 Mbps Ethernet segment, and the propagation delay between the two nodes is 225 bit times. Suppose A and B send frames at the same time, the frames collide, and then A and B choose different values of K in the CSMA/CD algorithm. Assuming no other nodes are active, can the retransmissions from A and B collide? For our purposes, it suffices to work out the following example. Suppose A and B begin transmission at t=0 bit times. They both detect collisions at t=225 bit times. They finish transmitting jam signal at t= 225+48= 273 bit times. Suppose KA=0 and KB=1. At what time does B schedule its retransmission? At what time does A begin transmission? (Note, the nodes must wait for an idle channel after returning to Step 2-- see protocol.) At what time does A's signal reach B? Does B refrain from transmitting at its scheduled time?

Time Event
0 A and B begin transmission
225 A and B detect collision
273 A and B finish transmitting jam signal
273+225=498 B 's last bit arrives at A ;A detects an idle channel
498+96=594 A starts transmitting
273+512=785 B returns to Step2
B must sense idle channel for 96 bit times before it transmits
785+96=881 B starts transmitting
594+225=819 A’s transmission reaches B
Because A 's retransmission reaches B before B 's scheduled retransmission time, B refrains from transmitting while A retransmits. Thus A and B do not collide. Thus the factor 512 appearing in the exponential backoff algorithm is sufficiently large.

20. Consider a 100Mbps 100-BT Ethernet. In order to have an efficiency of .50, what should be the maximum distance between a node and the hub? Assume a frame length of 64 bytes and that there are no repeaters. Does this maximum distance also ensure that a transmitting node A will be able to detect whether any other node transmitted while A was transmitting? Why or why not? How does your maximum distance compare to the actual 100 Mbps standard?
Ans>>We want 1/(1+ 5a) = .5 or, equivalently, prop trans a = .2 = t / t . t = d /(1.8 ×108 ) prop m/sec and = (576 trans t bits ) /(108 bits/sec ) = 5.76μ sec. Solving for d we obtain d = 265 meters. For the 100 Mbps Ethernet standard, the maximum distance between two hosts is 200 m.
For transmitting station A to detect whether any other station transmitted during A 's interval, trans t must be greater than 2 = 2 ⋅ 265 prop t m/1.8 ×108 m/sec = 2.94μ sec. Because 2.94 < 5.76 , A will detect B 's signal before the end of its transmission. 21. Suppose two nodes, A and B, are attached to opposite ends of a 900 m cable, and that they each have one frame of 1000 bits (including all headers and preambles) to send to each other. Both nodes attempt to transmit at time t=0. Suppose there are four repeaters between A and B, each inserting a 20 bit delay. Assume the transmission rate is 10 Mbps, and CSMA/CD with backoff intervals of multiples of 512 bits is used. After the first collision, A draws K=0 and B draws K=1 in the exponential backoff protocol. Ignore the jam signal.
a. What is the one-way propagation delay (including repeater delays) between A and B in seconds. Assume that the signal propagation speed is 2 * 108m/sec.
b. At what time (in seconds) is A's packet completely delivered at B.
c. Now suppose that only A has a packet to send and that the repeaters are replaced with bridges. Suppose that each bridge has a 20 bit processing delay in addition to a store-and-forward delay. At what time in seconds is A's packet delivered at B?

ANS>> a)
= (4.5 10-6+8 10-6)
=12.5µsec
b) frame transmission time is (1000bits/10*106bps)=100 μsec
At time t = 0 , both A and B transmit.
At time t = 12.5μ sec , A detects a collision.
At time t = 25μ sec last bit of B 's aborted transmission arrives at A .
At time t = 37.5μ sec first bit of A 's retransmission arrives at B .
At time t= 37.5 μsec + 100 μsec =137.5 μsecA 's packet is completely delivered at B .
c) 12.5μ sec+ 5⋅100μ sec = 512.5μ sec

Thursday, October 14, 2010

PHP interview questions and answers

1. What does a special set of tags do in PHP?
Ans - The output is displayed directly to the browser.

2. What’s the difference between include and require?
Ans - It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

3. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
Ans - PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.

4. Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?
Ans - In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.

5. How do you define a constant?
Ans - Via define() directive, like define ("MYCONSTANT", 100);

6. How do you pass a variable by value?
Ans - Just like in C++, put an ampersand in front of it, like $a = &$b

7. Will comparison of string "10" and integer 11 work in PHP?
Ans - Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.

8. When are you supposed to use endif to end the conditional statement?
Ans - When the original if was followed by : and then the code block without braces.

9. Explain the ternary conditional operator in PHP?
Ans - Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.

10. How do I find out the number of parameters passed into function?
Ans - func_num_args() function returns the number of parameters passed in.

11. If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?
Ans - 100, it’s a reference to existing variable.

12. What’s the difference between accessing a class method via -> and via ::?
Ans - :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.

13. Are objects passed by value or by reference?
Ans - Everything is passed by value.

14. How do you call a constructor for a parent class?
Ans - parent::constructor($value)

15. What’s the special meaning of __sleep and __wakeup?
Ans - __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

16. Would you initialize your strings with single quotes or double quotes?
Ans - Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution.

17. How come the code works, but doesn’t for two-dimensional array of mine?
Ans - Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would’ve worked.

18. What is the difference between characters �23 and x23?
Ans - The first one is octal 23, the second is hex 23.

19. With a heredoc syntax, do I get variable substitution inside the heredoc contents?
Ans - Yes.

20. I am writing an application in PHP that outputs a printable version of driving directions. It contains some long sentences, and I am a neat freak, and would like to make sure that no line exceeds 50 characters. How do I accomplish that with PHP?
Ans - On large strings that need to be formatted according to some length specifications, use wordwrap() or chunk_split().

21. What’s the difference between htmlentities() and htmlspecialchars()?
Ans - htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.

22. What’s the difference between md5(), crc32() and sha1() crypto on PHP?
Ans - The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.

23. So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?
Ans - Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.

24. How do you match the character ^ at the beginning of the string?
Ans - ^^

Tuesday, October 12, 2010

Java Thread Questions and answers

1. Do I need to use synchronized on setValue(int)?
Ans: 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)?
Ans: 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?
Ans: 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 objectrun() 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans : 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.

Friday, July 09, 2010

J2ee Interview Questions and Answers

1. What makes J2EE suitable for distributed multitiered Applications?
Ans : The J2EE platform uses a multitiered distributed application model. Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multitiered J2EE environment to which the application component belongs. The J2EE application parts are:

* Client-tier components run on the client machine.
* Web-tier components run on the J2EE server.
* Business-tier components run on the J2EE server.
* Enterprise information system (EIS)-tier software runs on the EIS server.

2. What is J2EE?
Ans : J2EE is an environment for developing and deploying enterprise applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitiered, web-based applications.

3. What do Enterprise JavaBeans components contain?
Ans : Enterprise JavaBeans components contains Business code, which is logic
that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier. All the business code is contained inside an Enterprise Bean which receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client program.

4. Is J2EE application only a web-based?
Ans : No, It depends on type of application that client wants. A J2EE application can be web-based or non-web-based. if an application client executes on the client machine, it is a non-web-based J2EE application. The J2EE application can provide a way for users to handle tasks such as J2EE system or application administration. It typically has a graphical user interface created from Swing or AWT APIs, or a command-line interface. When user request, it can open an HTTP connection to establish communication with a servlet running in the web tier.

5. Are JavaBeans J2EE components?
Ans : No. JavaBeans components are not considered J2EE components by the J2EE specification. They are written to manage the data flow between an application client or applet and components running on the J2EE server or between server components and a database. JavaBeans components written for the J2EE platform have instance variables and get and set methods for accessing the data in the instance variables. JavaBeans components used in this way are typically simple in design and implementation, but should conform to the naming and design conventions outlined in the JavaBeans component architecture.

6. Is HTML page a web component?
Ans : No. Static HTML pages and applets are bundled with web components during application assembly, but are not considered web components by the J2EE specification. Even the server-side utility classes are not considered web components, either.

7. What can be considered as a web component?
Ans : J2EE Web components can be either servlets or JSP pages. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content.

8. What is the container?
Ans : Containers are the interface between a component and the low-level platform specific functionality that supports the component. Before a Web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE application and deployed into its container.

9. What are container services?
Ans : A container is a runtime support of a system-level entity. Containers provide components with services such as lifecycle management, security, deployment, and threading.

10. What are the components of J2EE application?
Ans: A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and communicates with other components. The J2EE specification defines the following J2EE components:

1. Application clients and applets are client components.
2. Java Servlet and JavaServer Pages technology components are web components.
3. Enterprise JavaBeans components (enterprise beans) are business components.
4. Resource adapter components provided by EIS and tool vendors.



Monday, July 05, 2010

C Sharp Interview Questions and Answers

1. What’s the advantage of using System.Text.StringBuilder over System.String?
Ans : StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.

2. What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?
Ans : A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

3. Can multiple catch blocks be executed?
Ans : No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.

4. Why is it a bad idea to throw your own exceptions?
Ans : Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.

5. How’s the DLL Hell problem solved in .NET?
Ans : Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.

6. What’s a satellite assembly?
Ans : When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

7. What debugging tools come with the .NET SDK?
Ans : CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.

8. What does assert() do?
Ans : In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

9. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
Ans : The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.

10. What are three test cases you should go through in unit testing?
Ans : Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).

11. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
Ans : SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.

12. Explain ACID rule of thumb for transactions.
Ans : Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).



Sunday, June 27, 2010

IT Fundamental - X

1. On the motherboard (the) … is the temporary computer memory area in which data can be stored.
a. expansion slot
b. math co-processor
c. RAM
d. ROM BIOS

2. The device used in a data communication network to perform the conversion between analogue and digital signals, is called a …
a. front end processor.
b. modem.
c. decoder.
d. multiplexer.

3.If you look carefully at the motherboard, you will notice that some chips are soldered to the board whilst others are plugged into the board. The removable chips allow you to ...
a. add extra power sources to your computer.
b. integrate the ALU and the system clock unit.
c. re-arrange the layout of your motherboard.
d. upgrade your computer components.

4. The Internet offers different services. Which one listed below is incorrect?
a. Chat room
b. Electronic mail
c. Off line shopping
d. World Wide Web

5. The Internet is ...
a. a global network of computers networks.
b. a government-owned agency that links computers.
c. software for sending e-mail around the world.
d. a specialised form of local area network.

6. The CPU deals with each instruction in a cycle. The sequence of instructions to carry out one machine instruction is called the instruction or machine cycle. The first action is to fetch the instruction from memory and then the program counter is updated (reset). The other three phases of the machine cycle in the correct order are:
a. Decode the instruction; Execute the instruction; Transfer the data.
b. Decode the instruction; Transfer the data; Execute the instruction.
c. Execute the instruction; Decode the instruction; Transfer the data.
d. Transfer the data; Execute the instruction; Decode the instruction.

7. When the electrical power is disrupted or cut off, data and programs are lost in/on (the) ...
a. basic tools.
b. hard disk.
c. memory.
d. secondary storage.

8. The communication bus which is used to fetch the address of an instruction from memory is called the …
a. address bus.
b. control bus.
c. data bus.
d. fetch bus.

9. Read Only Memory (ROM)
i. Is volatile
ii. Is programmable
iii. Is mounted on the mother board
iv. Contains the bootstrap loader
a. i and iii
b. i, ii and iv
c. ii, iii and iv
d. iii and iv

10. An online meeting allows users to ...
a. determine the receiver's geographic location.
b. leave voice messages for one or two people.
c. print to a web address that is associated to a particular printer.
d. share documents with others in real time.

Friday, June 18, 2010

Software Engg. - III

1) Business model is the part of designing phase of software engineering development life cycle
a. True
b. False

2) The state transition diagram
a. depicts relationships between data objects
b. depicts functions that transform the data flow
c. indicates how data are transformed by the system
d. indicates system reactions to external events

3) The best way to conduct a requirements validation review is to
a. Examine the system
b. Have the customer look over the requirements
c. Send them to the design team
d. Use checklist to examine the questions

4) The system specification describes the
a. Function, performance and constraints of a computer-based system
b. implementation of each allocated system
c. time required for simulation
d. element software architecture

5) For each of the following given Requirement indicate whether it is Functional (F) or Non-Functional (N) Requirement.
a. The System should be designed so it can later be extended to a Blue Line
reservation System.(N)
b. The System will allow the user to view the layout of seats in Bus.(F)
c. The System must be available at all times.(N)
d. A given seat can be assigned to only one person.(F)

6)Both the software engineer and customer take an active role in software requirements engineering-a set of activities that is often referred to as Requirement_______________
a. Managing
b. Recognition
c. Analysis
d. Modeling

7)_________ is a measure of independence of a module or component.
a. Cohesion
b. Coupling
c. Loop coupling
d. Loop cohesion

8) In the Functional design, the structure of the system revolves around __________
a. Functions
b. Sequences
c. Models
d. Flows

9)Use case is the part of designing phase of software engineering
a. True
b. False

10) Three categories of risks are
a. Business, personnel risks, budget risks
b. project risks, technical risks, business risks
c. planning risks, technical risks, personnel risks
d. management risks, technical risks, design risks

Sunday, June 13, 2010

Software Engg. - II

1. Decomposing the major project deliverables into smaller, more manageable components to provide better control is called:
a) Project planning.
b) Scope definition.
c) Project base lining.
d) Requirements verification.

2. Select one aspect that is NOT included in a feasibility analysis for new system?
a) Organisational objectives
b) Cost effectiveness
c) Technical feasibility
d) Budgetary constraints
e) Requirements validation

3. One of the fundamental tenets of quality management is that quality:
a) Must exceed customer expectations.
b) Is planned in and not inspected in.
c) Will increase cost.
d) Costs must all be passed onto the customer.

4. In the Shewhart and Deming Quality cycle, the letters P D C A stands for:
a) Purchase, deliver, cost, and acquisition.
b) Prevent defects caused by anyone.
c) Plan, do, check, and act.
d) Please don’t cause accidents.

5. Which is NOT included in the software requirements specification?
a) test specifications for each mandatory requirement
b) project schedule and WBS
c) functional description of user requirements
d) performance description for each non-functional requirement
e) data dictionary

6. A data dictionary was created during the requirements analysis phase of a software engineering project. What information does it contain?
a) interface design criteria
b) data types and description of database table entries
c) restrictions on security
d) list of main functional requirements

7. A software project classifies system entities, their activities and relationships. The classification and abstraction of system entities is important. Which modelling methodology most clearly shows the classification and abstraction of entities in the system?
a) data flow model
b) event driven model
c) object oriented model
d) entity-relationship model

8. Which of the following is NOT a non-functional system requirement component?
a) cost
b) reliability
c) usability
d) performance
e) maintainability

9. What is the purpose of a test case specification in software engineering?
a) to specify the sequence of actions for the execution of a number of sequential tests
b) to specify inputs, predicted results, and a set of execution conditions for a test item
c) to list the test procedures to be performed on the integration of the system database
d) to report the specific tests results when integrating software modules

10. In the software testing process, when is validation testing performed?
a) after coding
b) after unit testing
c) after module testing
d) after integration testing

Saturday, June 12, 2010

C# DotNet Questions

1. What’s the implicit name of the parameter that gets passed into the class’ set method?
Value, and its datatype depends on whatever variable we’re changing.

2. How do you inherit from a class in C#?
Place a colon and then the name of the base class. Notice that it’s double colon in C++.

3. Does C# support multiple inheritance?
No, use interfaces instead.

4. When you inherit a protected class-level variable, who is it available to?
Classes in the same namespace.

5. Are private class-level variables inherited?
Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

6. Describe the accessibility modifier protected internal.
It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).

7. C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.

8. What’s the top .NET class that everything is derived from?
System.Object.

9. How’s method overriding different from overloading?
When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.

10. What does the keyword virtual mean in the method definition?
The method can be over-ridden.

11. Can you declare the override method static while the original method is non-static?
No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

12. Can you override private virtual methods?
No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.

13. Can you prevent your class from being inherited and becoming a base class for some other classes?
Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.

14. Can you allow class to be inherited, but prevent the method from being over-ridden?
Yes, just leave the class public and make the method sealed.

15. What’s an abstract class?
A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it’s a blueprint for a class without any implementation.

Sunday, May 23, 2010

Java Fundamental-X

1. What is J2EE Connector?
The J2EE Connector API is used by J2EE tools vendors and system integrators to create resource adapters that support access to enterprise information systems that can be plugged into any J2EE product. Each type of database or EIS has a different resource adapter.

2. What is JAAP?
The Java Authentication and Authorization Service (JAAS) provide a way for a J2EE application to authenticate and authorize a specific user or group of users to run it. It is a standard Pluggable Authentication Module (PAM) framework that extends the Java 2 platform security architecture to support user-based authorization.

3. What is Model 1?
Using JSP technology alone to develop Web page. Such term is used in the earlier JSP specification. Model 1 architecture is suitable for applications that have very simple page flow, have little need for centralized security control or logging, and change little over time. Model 1 applications can often be refactored to Model 2 when application requirements change.

4. What is Model 2?
Using JSP and Servlet together to develop Web page. Model 2 applications are easier to maintain and extend, because views do not refer to each other directly.

5. What is Struts?
A Web page development framework. Struts combine Java Servlets, Java Server Pages, custom tags, and message resources into a unified framework. It is a cooperative, synergistic platform, suitable for development teams, independent developers, and everyone between.

6. How is the MVC design pattern used in Struts framework?
In the MVC design pattern, application flow is mediated by a central Controller. The Controller delegates requests to an appropriate handler. The handlers are tied to a Model, and each handler acts as an adapter between the request and the Model. The Model represents, or encapsulates, an application's business logic or state. Control is usually then forwarded back through the Controller to the appropriate View. The forwarding can be determined by consulting a set of mappings, usually loaded from a database or configuration file. This provides a loose coupling between the View and Model, which can make an application significantly easier to create and maintain.
Controller--Servlet controller which supplied by Struts itself; View --- what you can see on the screen, a JSP page and presentation components; Model --- System state and a business logic JavaBeans.

7. What does web module contain?
The web module contains:
o JSP files,
o class files for Servlets,
o GIF and HTML files, and
o A Web deployment descriptor.
Web modules are packaged as JAR files with a .war (Web Archive) extension.

8. What APIs are available for developing a J2EE application?
o Enterprise JavaBeans Technology(3 beans: Session Beans, Entity Beans and Message-Driven Beans)
o JDBC API(application level interface and service provider interface or driver)
o Java Servlets Technology(Servlet)
o Java ServerPage Technology(JSP)
o Java Message Service(JMS)
o Java Naming and Directory Interface(JNDI)
o Java Transaction API(JTA)
o JavaMail API
o JavaBeans Activation Framework(JAF used by JavaMail)
o Java API for XML Processing(JAXP,SAX, DOM, XSLT)
o Java API for XML Registries(JAXR)
o Java API for XML-Based RPC(JAX-RPC)-SOAP standard and HTTP
o SOAP with Attachments API for Java(SAAJ)-- low-level API upon which JAX-RPC depends
o J2EE Connector Architecture
o Java Authentication and Authorization Service(JAAS)

Search Aptipedia