Anda di halaman 1dari 21

C#

1.

What are .NET assemblies? Whats the difference between private and shared assembly? Whats a strong name?

.NET assemblies
Assemblies are the basic building blocks required for any application to function in the .NET realm. They are partially compiled code libraries that form the fundamental unit of deployment, versioning, activation scoping, reuse, and security. Typically, assemblies provide a collection of types and resources that work together to form a logical unit of functionality. They are the smallest deployable units of code in .NET. Compared to the executable files assemblies are far more reliable, more secure, and easy to manage. An assembly contains a lot more than the Microsoft Intermediate Language (MSIL) code that is compiled and run by the Common Language Runtime (CLR) Private Assemblies:

The assembly is intended only for one application. The files of that assembly must be placed in the same folder as the application or in a sub folder. No other application will be able to make a call to this assembly. The advantage of having a private assembly is that, it makes naming the assembly very easy, since the developer need not worry about name clashes with other assemblies. As long as the assembly has a unique name within the concerned application, there wont be any problems.

Shared Assemblies: If the assembly is to be made into a Shared Assembly, then the naming conventions are very strict since it has to be unique across the entire system. The naming conventions should also take care of newer versions of the component being shipped. These are accomplished by giving the assembly a Shared Name. Then the assembly is placed in the global assembly cache, which is a folder in the file system reserved for shared assemblies.

A strong name consists of the assemblys identity its simple text name, version number, and culture information (if provided) plus a public key and a digital signature. Assemblies with the same strong name are expected to be identical. There are two ways to sign an assembly with a strong name:

1. 2.

Using the Assembly Linker (Al.exe) provided by the .NET Framework SDK. Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, depending

Q2.

Differentiate between i) ii) iii) iv) v) delegate and an events interface and an abstract class shadow and override StringBuilder and String class Var and dynamic keywords.

1. Delegates and events

Delegates in C# If we look at C++ there is a feature called callback function. This feature uses Pointers to Functions to pass them as parameters to other functions. Delegate is a similar feature but it is more type safe, which stands as a stark contrast with C++ function pointers. A delegate can hold reference/s to one more more functions and invoke them as and when needed. Any delegate is inherited from base delegate class of .NET class library when it is declared. This can be from either of the two classes from System.Delegate or System.MulticastDelegate If the delegate contains a return type of void, then it is automatically aliased to the type of System.MulticastDelegate Events in c# Delegate usefulness does not just lie in the fact that it can hold the references to functions but in the fact that it can define and use function names at runtime and not at compile time. A large goal of design delegates is their applicability in events model of .Net. Events are the actions of the system on user manipulations (e.g. mouse clicks, key press, timer etc.) or any event triggered by the program

2. Interface and abstract class 1) Abstract class defines few or none of the methods, but interface defines all the methods.. 2) Abstract classes should have subclasses else that will be useless. Interfaces must have implementations by other classes else that will be useless 3) only an interface can extend another interface, but any class can extend an abstract class. 4) A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class. 5) Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual class. Abstract classes are fast.

3. shadow and override 1. Overriding redefines only the implementation but shadowing redefines the whole Element. 2. In Overriding derived Class can refer the Base class using ME Keyword but in shadowing we can access it using "MYBase". 3. Shadowing hides a base class member in the derived by using the "New" keyword. It is used to explicitly hide a member inherited from base class. new and override both cannot be used for the same member. In Overriding methods have same names,same signatures,same return types but in different classes.C# uses virtual and override keyword for method overriding.

4. StringBuilder and String class String are Immutable (Not Modifiable). It uses Concatenation method If you try to modify the string it actually creates a new string and the old string will be then ready for garbage collection

for example String s1="loin"; string s2=s1.insert(3,"g"); now s2 have the value login ,but one thing to notice here is that we are not assigning this value into s1, because it is not possible in String class, but if we want to change the contents of s1 then we will have to take the String Builder class because with the help of this class we can change the contents of same string String Builder when instantiated, uses Append Method creates a new string with predefined capacity and up to that capacity it can accommodate string without needing to create a new memory location for the string

For Example: String s1="loin"; s1=s1.insert (3,"g");

now s1 is "login here we are assigning the value again in s1,this is the main difference between in string and string Builder class

5.

Var and dynamic keywords

Var

Var Can able to store any type of value but it requires to initialize at the time of declaration. It's compiler safe i.e. compiler has all information about the stored value, so that it doesn't cause any issue at run-time. Var type cannot be passed as function argument and function can not return object type. This type of variable can work in the scope where it defined.

Dynamic

Dynamic Can able to store any type of the variable, similar to old VB language variable
Compiler doesn't have any information about the this type of variable. Dynamic type can be passed as function argument and function also can return object type.

3. Explain the concept of Hash Table, ArrayList, Dictionary, Stack and List collection.

HashTable - A basic key-value-pair map that functions like an indexed list. ArrayList - An array-based list that doesn't support generic types. It does not enforce type safety and should generally be avoided

Dictionary - A hashtable that supports generic types and enforces type-safety Stack - A LIFO list where you push/pop records on top of each other.

List collection Lists are considered generics and constructed types. You need to use < and > in the List declaration. Lists handle any element type.

using System.Collections.Generic; class Program { static void Main() { List<int> list = new List<int>(); list.Add(2); list.Add(3); list.Add(5); list.Add(7); } }

4. What are extension methods in LINQ. Explain with example. Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type. For client code written in C# and Visual Basic, there is no apparent difference between calling an extension method and the methods that are actually defined in a type.

Example:: class ExtensionMethods2 { static void Main() { int[] ints = { 10, 45, 15, 39, 21, 26 }; var result = ints.OrderBy(g => g); foreach (var i in result) { System.Console.Write(i + " "); } } } //Output: 10 15 21 26 39 45

5. What is DLL Hell problem. Explain how DLL Hell problem solved in .NET ? Windows registry cannot maintain multiple versions of the same library because of this when it comes to deployment. Old version is trying to override new version clash will take place. This will terminates installation process. This problem is called as DLL HELL. DLL Hell problem is solved in .NET with the introduction of Assembly versioning. It allows the application to specify not only the library it needs to run, but also the version of the assembly.
Global assembly Cache (GAC) solves the dll hell problem.When a .Net component/dll is installed onto the machine, the Global Assembly Cache looks at its version, its public key, and its language information and creates a strong name for the component/dll

JAVA

1. Explain Networking using TCP/IP and UDP protocols.

TCP (Transmission Control Protocol) is a connection-based protocol that provides a reliable flow of data between two computers.TCP provides a point-to-point channel for applications that require reliable communications. The Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), and Telnet are all examples of applications that require a reliable communication channel. The order in which the data is sent and received over the network is critical to the

success of these applications. When HTTP is used to read from a URL, the data must be received in the order in which it was sent. Otherwise, you end up with a jumbled HTML file, a corrupt zip file, or some other invalid information. TCP sockets can perform a variety of operations. They can: Establish a connection to a remote host Send data to a remote host Receive data from a remote host Close a connection java.net.Socket Constructors Socket (InetAddress address int port) throws java.io.IOException, Socket (InetAddress address, int port, InetAddress localAddress int localPort) throws java.io.IOException

Socket (String host, int port, InetAddress localAddress, int localPort) throws java.net.UnknownHostException,
UDP (User Datagram Protocol) is a protocol that sends independent packets of data, called datagrams, from one computer to another with no guarantees about arrival. UDP is not connection-based like TCP.The UDP protocol provides for communication that is not guaranteed between two applications on the network. UDP is not connection-based like TCP. Rather, it sends independent packets of data, called datagrams, from one application to another. Sending datagrams is much like sending a letter through the postal service: The order of delivery is not important and is not guaranteed, and each message is independent of any other. Java supports the User Datagram Protocol in the form of two classes: java.net.DatagramPacket The DatagramPacket class represents a data packet intended for transmission using the User Datagram Protocol Constructors: DatagramPacket(byte[] buffer, int length). Eg. DatagramPacket packet = new DatagramPacket(new byte[256], 256); DatagramPacket(byte[] buffer, int length, InetAddress dest_addr, int dest_port) Eg..InetAddress addr = InetAddress.getByName("192.168.0.1"); DatagramPacket packet = new DatagramPacket ( new byte[128],128, addr, 2000); java.net.DatagramSocket

A DatagramSocket can be used to both send and receive packets. Each DatagramSocket binds to a port on the local machine, which is used for addressing packets. Constructors DatagramSocket(int port) throws java.net.SocketException DatagramSocket (int port, InetAddress addr) throwsjava.net.SocketException.

2. Explain and compare features of Swings with AWT

Swing implements a set of GUI components that build on AWT technology and provide a pluggable look and feel. Swing is implemented entirely in the Java programming language, and is based on the JDK 1.1 Lightweight UI Framework. Swing features include:

All the features of AWT. 100% Pure Java certified versions of the existing AWT component set (Button, Scrollbar, Label, etc.). A rich set of higher-level components (such as tree view, list box, and tabbed panes). Pure Java design, no reliance on peers. Pluggable Look and Feel.

AWT stands for Abstract Window ToolKit. The Abstract Window Toolkit supports GUI Java programming. It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window Toolkit provides the connection between your application and the native GUI. The AWT provides a high level of abstraction for your Java program since it hides you from the underlying details of the GUI your program will be running on

AWT features include:

A rich set of user interface components. A robust event-handling model. Graphics and imaging tools, including shape, color, and font classes. Layout managers, for flexible window layouts that don't depend on a particular window size or screen resolution. Data transfer classes, for cut-and-paste through the native platform clipboard.

3. Explain the architecture of Java Bean. Write an example how to create a bean and

how to add properties to a Java Bean and how to generate and receive property change events. JavaBeans is an architecture for both using and building components in Java. This architecture supports the features of software reuse, component models, and object orientation. One of the most important features of JavaBeans is that it does not alter the existing Java language. If you know how to write software in Java, you know how to use and create Beans. The strengths of Java are built upon and extended to create the JavaBeans component architecture. Example
public class MyBean implements java.io.Serializable { protected int theValue; public MyBean() { } public void setMyValue(int newValue) { theValue = newValue; } public int getMyValue() { return theValue; } }

4. What is RMI ?Explain architecture of RMi ? write down the steps how stub and

skeleton is created using RMI.. The Java Remote Method Invocation (RMI) system allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine. RMI provides for remote communication between programs written in the Java programming language.

Architecture
There are three layers that comprise the basic remote-object communication facilities in RMI:

The stub/skeleton layer, which provides the interface that client and server application objects use to interact with each other. The remote reference layer, which is the middleware between the stub/skeleton layer and the underlying transport protocol. This layer handles the creation and management of remote object references. The transport protocol layer, which is the binary data protocol that sends remote object requests over the wire.

The rmic compiler generates stub, and skeleton class files (JRMP protocol), and stub and tie class files (IIOP protocol) for remote objects. These classes files are generated from the compiled Java programming language classes that contain remote object implementations. A remote object is one that implements the interface java.rmi.Remote. The classes named in the rmic command must be classes that have been compiled successfully with the javac command and must be fully package qualified. For eg. % rmic -d C:\java\classes foo.MyClass

5. Explain JDBC Models,Result Set and Prepared Statements.

The JDBC API supports both two-tier and three-tier processing models for database access.
In the two-tier model, a Java applet or application talks directly to the data source. This requires a JDBC driver that can communicate with the particular data source being accessed. A user's commands are delivered to the database or other data source, and the results of those statements are sent back to the user. The data source may be located on another machine to which the user is connected via a network. This is referred to as a client/server configuration, with the user's machine as the client, and the machine housing the data source as the server. The network can be an intranet, which, for example, connects employees within a corporation, or it can be the Internet.

In the three-tier model, commands are sent to a "middle tier" of services, which then sends the commands to the data source. The data source processes the commands and sends the results back to the middle tier, which then sends them to the user. MIS directors find the three-tier model very attractive because the middle tier makes it possible to maintain control over access and the kinds of updates that can be made to corporate data. Another advantage is that it simplifies the deployment of applications. Finally, in many cases, the three-tier architecture can provide performance advantages.

Result Set The number of rows returned in a result set can be zero, one, or many. A user can access the data in a result set one row at a time, and a cursor provides the means to do that. A cursor can be thought of as a pointer into a file that contains the rows of the result set, and that pointer has the ability to keep track of which row is currently being accessed
Prepared Statement

The main feature of a PreparedStatement object is that, unlike a Statement object, it is given a SQL statement when it is created. The advantage to this is that in most cases, this SQL statement is sent to the DBMS right away, where it is compiled. As a result, the PreparedStatement object contains not just a SQL statement, but a SQL statement that has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement SQL statement without having to compile it first.

DCN
1. Datagram subnets route each packets as a separate unit, independent of all others. Virtual circuit subnets do not do this, since each data packet follows a predetermined route. Does this observation mean that virtual circuit subnets do not need the capability to route isolated packet from arbitrary source to an arbitrary destination? Explain your answer.
No, it does not. In virtual-circuit subnets, routers have to route packets based on the following pieces of information:

- Virtual-Circuit number - Incoming line Each packet contains a Virtual-Circuit number and the incoming line identification is, of course, known by the router. Finally, to re-estate the observation, virtual-circuit subnets do need the capability to route isolated packets from an arbitrary incoming line (which is well known by the router) and with an arbitrary circuit number (information carried in the packet). That means, knowing the original source and the final destination is not required

Q2. (a) When the bandwidth or the maximum distance between two farthest nodes increase, the minimum size of the frame dose not remain appropriate. Why? (b) In Go-Back-N, the sequence numbers should be one more than the size of buffer. Why?

(b). The method then determines if a packet is an out of window packet and buffers out-of-window
packets having a sequence number more than a first number. The method delivers a packet when the packet sequence number matches a first number. It delivers all buffered packets when a timeout occurs. A communication system having at least one network device that performs this method is also disclosed.

Q3. (a)What advantages does TCP have cover UDP? What are the features, which make TCP a reliable protocol? (b)What is meant by TCP handoff? Ans. (a )
TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are two protocols that run on the forth layer of OSI layers. There are many advantages of using TCP over UDP. TCP as we know is a connection based protocol, meaning that a connection needs to be setup before the transfer of data can start. To be able to do that TCP has been designed with the 3-way handshake system. In this system a user who wants to send data initializes the connection and is acknowledged by the receiving end. Once acknowledged, the sender acknowledges the Acknowledgement, thus completing the 3-way handshake. In this way, TCP can establish a connection. TCP is a reliable protocol, meaning that the data that is sent is reached by the receiving party, which is not an entity in UDP. Data packets that are lost are resent again, if the connection fails then the data is re-requested, thus making sure that data is received at the other end.

(B) TCP handoff is a technique to handoff one TCP socket endpoint from one node to the other
seamlessly, which is to migrate the established TCP state from the original node to the new node, so that the new node can send packets to the other TCP endpoint directly. TCP handoff is mostly used to do content-aware request distribution among servers, which enables intelligent distribution to provide quality of service requirements for different types of contents and to improve overall cluster performance.

Q4. What Policies are used to prevent and control congestion in Transport Layer? Define them.

Open-Loop Congestion Control(Prevention)


In open-loop congestion control, policies are applied to prevent congestion before it happens. In these mechanisms, congestion control is handled by either the source or the destination. Retransmission Policy Retransmission is sometimes unavoidable. If the sender feels that a sent packet is lost

or corrupted, the packet needs to be retransmitted. Retransmission in general may increase congestion in the network. A good retransmission policy can prevent congestion. The retransmission policy and the retransmission timers must be designed to optimize efficiency and at the same time prevent congestion. Window Policy The type of window at the sender may also affect congestion. The Selective Repeat window is better than the Go-Back-N window for congestion control. In the Go-Back-N window, when the timer for a packet times out, several packets may be resent, although some may have arrived safe and sound at the receiver. This duplication may make the congestion worse. The Selective Repeat window, on the other hand, tries to send the specific packets that have been lost or corrupted

Acknowledgment Policy The acknowledgment policy imposed by the receiver may also affect congestion. If the receiver does not acknowledge every packet it receives, it may slow down the sender and help prevent congestion. Several approaches are used in this case. A receiver may send an acknowledgment only if it has a packet to be sent or a special timer expires. A receiver may decide to acknowledge only N packets at a time.

Discarding Policy A good discarding policy by the routers may prevent congestion and at the same time may not harm the integrity of the transmission. For example, in audio transmission, if the policy is to discard less sensitive packets when congestion is likely to happen, the quality of sound is still preserved and congestion is prevented or alleviated. Admission Policy An admission policy, which is a quality-of-service mechanism, can also prevent congestion in virtual-circuit networks. Switches in a flow first check the resource requirement of a flow before admitting it to the network. A router can deny establishing a virtualcircuit connection if there is congestion in the network or if there is a possibility of future congestion.

Closed-Loop Congestion Control


Closed-loop congestion control mechanisms try to alleviate congestion after it happens. Several mechanisms have been used by different protocols. We describe a few of them here.
Backpressure The technique of backpressure refers to a congestion control mechanism in which a congested node stops receiving data from the immediate upstream node or nodes. This may cause the upstream node or nodes to become congested, and they, in turn, reject data from their upstream nodes or nodes. And so on.

Choke Packet A choke packet is a packet sent by a node to the source to inform it of congestion. Note the difference between the backpressure and choke packet methods. In backpressure, the warning is from one node to its upstream node, although the warning may eventually reach the source station. In the choke packet method, the warning is from the router, which has encountered congestion, to the source station directly

Implicit Signaling In implicit signaling, there is no communication between the congested node or nodes and the source. The source guesses that there is a congestion somewhere in the network from other symptoms.

Explicit Signaling The node that experiences congestion can explicitly send a signal to the source or destination. The explicit signaling method, however, is different from the choke packet method. In the choke packet method, a separate packet is used for this purpose; in the explicit signaling method, the signal is included in the packets that carry data. Explicit signaling, as we will see in Frame Relay congestion control, can occur in either the forward or the backward direction.

5. Explain Ethernet Protocol in detail.

Ethernet Protocol The Ethernet protocol is made up of a number of components, such as the structure of Ethernet frames, the Physical Layer and its MAC operation. This page will detail the fundamental structure of the Ethernet Protocol. Frame Structure Information is sent around an Ethernet network in discreet messages known as frames. The frame structure is quite simple, consisting of the following fields:

The Preamble - This consists of seven bytes, all of the form "10101010". This allows the receiver's clock to be synchronised with the sender's. The Start Frame Delimiter - This is a single byte ("10101011") which is used to indicate the start of a frame. The Destination Address - This is the address of the intended recipient of the frame. The addresses in 802.3 use globally unique hardwired 48 bit addresses. The Source Address - This is the address of the source, in the same form as above. The Length - This is the length of the data in the Ethernet frame, which can be anything from 0 to 1500 bytes. Data - This is the information being sent by the frame. Pad - 802.3 frame must be at least 64 bytes long, so if the data is shorter than 46 bytes, the pad field must compensate. The reason for the minimum length lies with the collision detection mechanism. In CSMA/CD the sender must wait at least two times the maximum propagation delay before it knows that no collision has occurred. If a station sends a very short message, then it might release the ether without knowing that the frame has been corrupted. 802.3 sets an upper limit on the propagation delay, and the minimum frame size is set at the amount of data which can be sent in twice this figure. Checksum - This is used for error detection and recovery

TOC
1. Explain LR(1) parsing with an example. LR(1) Parser In LR(0) action table, all entries in a row of a state contain the same reduce action in all columns. Therefore, reduce is performed independent of next input symbol. In LR(1), the Action table makes the difference. The lookahead symbol is used to decide if a reduction is applicable. Hence, the lookahead symbol resolves possible shift-reduce or reduce-reduce conflicts. Therefore, in LR(1) table, unlike LR(0) table, a row can have different reduce actions in different columns. An LR(1) item is a production with a marker together with a terminal, e.g., [S a A B e, c]. To reduce by this rule, it is necessary that next character should be c. By incorporating such lookahead information into the item concept, we can make wiser reduce decisions.

2. Differentiate between context sensitive and context free languages. Give examples. Also explain their respective automata.

Context Free Languages There is a finite set of symbols that form the strings, i.e. there is a finite alphabet. The alphabet symbols are called terminals(think of a parse tree) A CFG G may then be represented by these four components, denoted G=(V,T,R,S) V is the set of variables T is the set of terminals R is the set of production rules S is the start symbol.

Context Sensitive Grammar(Type1 Grammar) A context-sensitive grammar (CSG) is an unrestricted grammar in which every production has the form AB with |B|>=|A| where A and B are strings of nonterminal and Terminals A Context Sensitive Grammar is a 4-tuple , G = (N, , P, S) where: N=Set of non terminal symbols. =Set of terminal symbols. S=Start symbol of the production. P=Finite set of productions.

1. Prove that the following are equivalent to a standard TM: a. automata with semi-infinite tape b. TM with stay option (A.)automata with semi-infinite tape

(5)..What is decidability? Prove that the halting problem of TM is undecidable

In decibility let L be the language if L is Turing decidable (or just decidable) if there exists a Turing machine M that accepts all strings in L and rejects all strings not in L. Note that by rejection we mean that the machine halts after a finite number of steps and announces that the input string is not acceptable. Acceptance, as usual, also requires a decision after a finite number of steps.

b. TM with stay option

Anda mungkin juga menyukai