Lets open the Gate to the IITs.

Google Search

Wednesday, October 2, 2013

Books I recommend


Books I recommend  for gate preparation


COMPILERS

Compilers : Principles, Techniques , Alfred V. Aho, Compiler design O.G kakde http://lambda.uta.edu/cse5317/notes/node1.html

THEORY OF COMPUTATION

Introduction to Automata Theory, Languages and Computation , John E. Hopcroft,
Formal Languages And Automata Theory , K V N Sunitha, N Kalyani 


OPERATING SYSTEM

Operating System Concepts by Galvin,Silberswatz 
SCHAUM SERIES , Archer J Harris 


DATA STRUCTURE


Data StructuresandProgram Designin C++ Prentice Hall ,Robert L. Kruse Alexander
Data Structures (Schaum’s Outline Series) by Seymore Lipshutz 
Fundamentals of Data Structures in C 2nd by Sartaj Sahni

DIGITAL LOGIC 

Digital Logic Design by Morris Mano
Fundamentals of digital circuit by anand kumar 


COMPUTER ARCHITECTURE 


Computer System Architecture by Morris Mano
fundamental of computer architecture , Mostafa Abd-El-Barr ,Hesham El-Rewini 



COMPUTER NETWORKS

computer networks by Andrew S Tanenbaum 

DATABASE

Database System Concepts by Korth,Sudershan & Silberswatz
Fundamental Of Database Systems by Elmsari, Navathe
Schaum's Outline of Fundamentals of Relational Databases 

ALGORITHM

Introduction to Algorithms , CLRS
Algorithms , Dasgupta ,vazirani 

MATHS

Elements of Discrete Mathematics : C l Liu
Introduction to Graph Theory , Douglas B. West 
Higher Engineering Mathematics B,S grewal // one serious advise don't read this book crappy book only good if you already know maths no learning curve. good alternative for this will be Advanced Engineering Mathematics by Erwin Kreyszig 


Software/web tech/aptitude/English is more or less like general knowledge 

Some books  may not be the best book but they are very easy to understand and will develop your interest.

SQL Basics (DBMS)


1. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?
Data Definition Language (DDL)

2. What operator performs pattern matching?
LIKE operator

3. What operator tests column for the absence of data?
IS NULL operator

4. Which command executes the contents of a specified file?
START <filename> or @<filename>

5. What is the parameter substitution symbol used with INSERT INTO command?
&

6. Which command displays the SQL command in the SQL buffer, and then executes it?
RUN

7. What are the wildcards used for pattern matching?
_ for single character substitution and % for multi-character substitution

8. State true or false. EXISTS, SOME, ANY are operators in SQL.
True

9. State true or false. !=, <>, ^= all denote the same operation.
True

10. What are the privileges that can be granted on a table by a user to others?
Insert, update, delete, select, references, index, execute, alter, all

11. What command is used to get back the privileges offered by the GRANT command?
REVOKE

12. Which system tables contain information on privileges granted and privileges obtained?
USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD

13. Which system table contains information on constraints on all the tables created?
USER_CONSTRAINTS

14. TRUNCATE TABLE EMP;
DELETE FROM EMP;
Will the outputs of the above two commands differ?
Both will result in deleting all the rows in the table EMP.

15. What is the difference between TRUNCATE and DELETE commands?
TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled back. WHERE clause can be used with DELETE and not with TRUNCATE.

16. What command is used to create a table by copying the structure of another table?
Answer :
CREATE TABLE .. AS SELECT command
Explanation :
To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following.
CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;
If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table

Monday, September 30, 2013

CN Que (41-60)

41. What is multicast routing?
 
Sending a message to a group is called multicasting, and its routing algorithm is called multicast routing.

42. What is Mail Gateway?
 
It is a system that performs a protocol translation between different electronic mail delivery protocols.

43. What is IP address?
 
The internet address (IP address) is 32bits that uniquely and universally defines a host or router on the internet. The portion of the IP address that identifies the network is called netid. The portion of the IP address that identifies the host or router on the network is called hostid.

44. What do you mean by subnetting?
 
Subnetting divides one large network into several smaller ones. It adds an intermediate level of hierarchy in IP addressing.

45. What is Firewalls?
 
It is an electronic downbridge which is used to enhance the security of a network. It’s configuration has two components.

Two routers 
Application gateway

46. What is Repeaters ?
 
A receiver receives a signal before it becomes too weak or corrupted, regenerates the original bit pattern, sand puts the refreshed copy back onto the link. It operates on phycal layer of OSI model.

47. What is Bridges?

They divide large network into smaller components.They can relay frames between two originally separated LANs. They provide security through partitioning traffic. They operate on phycal and data link layer of OSI model.

48. What is Gateway ?
 
It is a protocol converter.A gateway can accept a packet formatted for one protocol and convert it to a packet formatted for another protocol. It operates on all the seven layers of OSI model.

49. What do you mean by peer ?
 
Entities comprising the corresponding layers on different machines are called peers.

50. What do you mean by broadcasting ?
 
Broadcast system allow addressing a packet to all destination by using a special code in address field. when packet is transmitted it is received and processed by every machine on the network.

51. What is source route?
 
It is a sequence of IP addresses identifying the route a datagram must follow. A source route may optionally be included in an IP datagram header.

52. What are major types of networks?
 
Server-based network

Peer-to-peer network

53. What are the protocols in application layer ?
 
The protocols defined in application layer are
TELNET
FTP
SMTP
SMTP

54. What do you mean by point to point network?
 
Point to point network consist of many connections between individual pair of machines.large networks are point to point.Routing algorithm plays an important in point to point network.It uses stored ad forword technique.It is a packet switching network.

55. Define Retransmission?
 
Retransmission is a technique in which the receiver detects the occurrence of an error and asks the sender to resend the message. Resending is repeated until a message arrives that the receiver believes is error-freed.

56. What are major types of networks?
 
Server-based network

Peer-to-peer network

57. What are the protocols in application layer ?
 
The protocols defined in application layer are
TELNET
FTP
SMTP
SMTP

58. What do you mean by point to point network?
 
Point to point network consist of many connections between individual pair of machines.large networks are point to point.Routing algorithm plays an important in point to point network.It uses stored ad forword technique.It is a packet switching network.

59. What are the protocols in transport layer ?
 
The protocols defined in transport layer are :
TCP
UDP

60. Define TCP ?
 
It is connection oriented protocol.It consist byte streams oeiginating on one machine to be delivered without error on any other machine in the network.while transmitting it fragments the stream to discrete messages and passes to interner layer.At the destination it reassembles the messages into output stream.

Sunday, September 29, 2013

CN Questions (21-40)

21. What is Bandwidth?
 
Every line has an upper limit and a lower limit on the frequency of signals it can carry. This limited range is called the bandwidth.

22. What is point-to-point protocol?
 
A communications protocol used to connect computers to remote networking services including Internet service providers.

23. What is switching?
 
Switching in data communication is of three types
Circuit switching
Packet switching
Message switching

24. Compare analog and digital signals?
 
Analog signals can have an infinite number of values in a range but digital signal can have only a limited number of values.

25. What is the difference between ARP and RARP?
 
ARP - Address resolution protocol is used to associate the 32 bit IP address with the 48 bit physical address, used by a host or a router to find the physical address of another host on its network by sending a ARP query packet that includes the IP address of the receiver.

RARP - Reverse address resolution protocol allows a host to discover its Internet address when it knows only its physical address.

26. What is ICMP?
 
ICMP is Internet Control Message Protocol, a network layer protocol of the TCP/IP suite used by hosts and gateways to send notification of datagram problems back to the sender.

27. What is logical link control?
 
One of two sublayers of the data link layer of OSI reference model, as defined by the IEEE 802 standard. This sublayer is responsible for maintaining the link between computers when they are sending data across the physical network connection.

28. What is difference between baseband and broadband transmission?
 
In a baseband transmission, the entire bandwidth of the cable is consumed by a single signal. In broadband transmission, signals are sent on multiple frequencies, allowing multiple signals to be sent simultaneously.

29. What is mesh network?

A network in which there are multiple network links between computers to provide multiple paths for data to travel.

30. Define bit rate and bit interval?
 
Digital signals are aperiodic.so instead of using period and frequency we use bit interval and bit rate respectively.Bit interval is the time required to send one single bit.Bit rate is the number of bit intervals per second.

31. What is sampling?
 
It is the process of obtaining amplitude of a signal at regular intervals.

32. Define pulse amplitude modulation?
 
It is an analog to digital conversion method which takes analog signals, samples it and generates a series of pulse based on the results of the sampling. It is not used in data communication because the series of pulses generated still of any amplitude. To modify it we use pulse code modulation.

33. What is Nyquist Theorem?
 
According to this theorem, the sampling rate must be at least 2 times the highest frequency of the original signal.

34. What is Asynchronous mode of data transmission?
 
It is a serial mode of transmission.In this mode of transmission, each byte is framed with a start bit and a stop bit. There may be a variable length gap between each byte.

35. What are the different types of multiplexing?
 
Multiplexing is of three types. Frequency division multiplexing and wave division multiplexing is for analog signals and time division multiplexing is for digital signals.

36. What MAU?
 
In token Ring, hub is called Multistation Access Unit(MAU).

37. What do you mean by switching?
 
It is a method in which communication devices are connected to one another efficiently.A switch is intermediary hardware or software that links devices together temporarily.

38. What do you mean by flow control?
 
It is the regulation of sender’s data rate so that the receiver buffer doesn’t become overwhelmed.i.e. flow control refers to a set of procedures used to restrict the amount of data that the sender can send before waiting for acknowledgement.

39. What do you mean by Bluetooth?
 
It is a wireless LAN technology designed to connect devices of different functions such as telephones, notebooks, computers, cameras, printers and so on. Bluetooth LAN Is an adhoc network that is the network is formed spontaneously? It is the implementation of protocol defined by the IEEE 802.15 standard.

40. What is virtual channel?
 
Virtual channel is normally a connection from one source to one destination, although multicast connections are also permitted. The other name for virtual channel is virtual circuit.

Saturday, September 28, 2013

Instrusction to the Applicants

This is the instructions which is given after filling up the form:

1. This print out should contain the following pages.

(a) Page 1 : This page contains Instructions and Address Slip (cut and paste the Address Slip on A4 size envelope).
(b) Page 2 : Application form that you have filled online.

2. Bank challan in Triplicate is available as a separate pdf file to be downloaded. This is available only if you have opted for Offline Payment.

3. On the GATE 2014 Application Form, paste a 3.5cm x 4.5cm color photograph with plain background (this should be the same that you have uploaded during application filling). The photograph should be taken in a studio.

(a) Write your Enrolment ID. and Name on the reverse side of the photo.
(b) Use good quality glue to ensure that the photograph does not separate from the application.
(c) Do not pin, staple, sign or attest the photograph.

4. Read the declaration and put your full signature in the box next to it. Please note that signature should not be in capital letters.

5. If you are in the final year or you have a backlog after appearing for the final year examination, you must get your Principal’s or HOD’s Signature and Seal in the Certificate from Principal that is provided at the last portion of the application form. Submit the whole form to the Principal’s office without cutting it.

6. If you have opted for challan payment, wait for 48 hours after your online submission to visit the bank’s branch. You can visit any branch of the bank printed on your challan.

7. The bank teller will verify the details printed on the challan with the data available in their system and then accept the payment.The bank will retain one copy and give you the remaining two copies: one of which is the GATE Copy that you have to send alongwith the printed application form and the other is the Candidate Copy for your reference.

8. Keep a photo copy of the completed application form for your reference.

9. Mailing Documents to GATE office.

(a) Cut the Address Slip and paste it onto an A4 size envelope (Do not fill address by hand or tamper the address slip).
(b) Collect the supporting documents shown under Enclosure Checklist in the application form. Mark the enclosures in the checklist boxes.
(c) Do NOT FOLD the application form and Do NOT STAPLE or pin the documents to the form.
(d) Send the packet by Speed Post (preferably) or by Registered Post to the address mentioned in the address slip. The application packet should REACH the respective zonal GATE office on or before Thursday, 10 October 2013.

20 QUE IN CN

1. What is a network?
 
It is a set of devices connected by communication links. A node can be a computer or any other device capable of sending and/or receiving data generated by other nodes on the network.

2. What is a protocol?
 
It is a set of rules that governs data communication.

3. What is multiplexing?
 
Multiplexing is the process of dividing a link, the phycal medium, into logical channels for better efficiency. Here medium is not changed but it has several channels instead of one.

4. Define bandwidth?
 
The range of frequencies that a medium can pass is called bandwidth. It is the difference between the highest and lowest frequencies that the medium can satisfactorily pass.

5. What do you mean by switching?
 
It is a method in which communication devices are connected to one another efficiently. A switch is intermediary hardware or software that links devices together temporarily.

6. What are the important topologies for networks?
 
BUS topology
STAR topology
RING topology
MESS topology

7. What are the duties of data link layer?
 
Data link layer is responsible for carrying packets from one hop (computer or router) to the next. The duties of data link layer include packetizing, adderssing, error control, flow control, medium access control.

8. What is virtual channel?
 
Virtual channel is normally a connection from one source to one destination, although multicast connections are also permitted. The other name for virtual channel is virtual circuit.

9. What is multicast routing?
 
Sending a message to a group is called multicasting, and its routing algorithm is called multicast routing.

10. What is TELNET ?
 
TELNET is a client - server application that allows a user to log on to a remote machine,giving the user access to the remote system. TELNET is an abbreviation of terminal network.

11. What do you mean by data communication?
 
It is the exchange of data between two devices via some form of transmission medium such as wire cable. The communicating system must be part of a communication system made up of a combination of hardware and software.The effectiveness of a data communication system depends on three fundamental characteristics: delivery, accuracy and timeliness.

12. What is distributed processing?
 
It is a strategy in which services provided by the network reside at multiple sites.

13. What is point to point connection?
 
It provides a dedicated link between two devices. The entire capacity of the link is reserved for transmission between the two devices.

14. What is Redundancy?
 
The concept of including extra information in the transmission solely for the purpose of comparison. This technique is called redundancy.

15. What is subnet?
 
A generic term for section of a large networks usually separated by a bridge or router.

16. What is multipoint connection?
 
In multipoint connection more than two specific devices share a single link. Here the capacity of the channel is shared either separately or temporally.

17. What is simplex?
 
It is the mode of communication between two devices in which flow of data is unidirectional.

18. What is half-duplex?
 
It is the mode of communication between two devices in which flow of data is bidirectional but not at the same time. ie each station can transmit and receive but not at the same time.

19. What is full duplex?
 
It is the mode of communication between two devices in which flow of data is bidirectional and it occurs simultaneously. Here signals going in either direction share the capacity of the link.

20. What is a topology?
 
Topology of a network is defined as the geometric representation of the relationship of all the links and linking devices (node) to one another .

Thursday, September 19, 2013

The DBMS..

Que 1 - What is a Database?
Ans : Database Management system is a collection of programs that enables user to create and maintain a database.
Thus a DBMS is a general purposed s/w system that facilitates the process of defining constructing and manipulating a database for various applications. (Defining a data base involves specifying the data types, structures and constraints for the data to be stored in the data database.
Constructing a data base is the process of storing data itself on some storage medium that is controlled by DBMS. Manipulating a database includes such functions as querying the data base to retrieve specific data, updating the database to reflect the changes in the mini-world.

Que 2 - What is a Catalog?
Ans : A catalog is a table that contain the information such as structure of each file , the type and storage format of each data item and various constraints on the data. The information stored in the catalog is called Metadata . Whenever a request is made to access a particular data, the DBMS s/w refers to the catalog to determine the structure of the file.

Que 3 - What is data ware housing & OLAP?
Ans : Data warehousing and OLAP (online analytical processing ) systems are the techniques used in many companies to extract and analyze useful information from very large databases for decision making .

Que 4 - What is real time database technology?
Ans : These are all the techniques used in controlling industrial and manufacturing processes.

Que 5 - What is program-data independence?
Ans : Unlike in the traditional file sys. the structure of the data files is stored in the DBMS catalog separately from the access programs . This property is called program-data independence.i.e. We needn’t to change the code of the DBMS if the structure of the data is changed .Which is not supported by traditional file sys .

Que 6 - What is ORDBMS?
Ans : Object oriented RDBMS is a relational DBMS in which every thing is treated as objects. User can define operations on data as a part of the database definition.

Que 7 - What is program-operation independence?
Ans : An operation is specified in two parts .
1. Interface (operation name and data types of its arguments).
2. Implementation (the code part)
The implementation part can be changed without affecting the interface. This is called program-operation independence.

Que 8 - What is a view?
Ans : A view may be a subset of the database or it may contain virtual data that is derived from the database files but is not explicitly stored.

Que 9 - What is OLTP?
Ans : Online transaction processing is an application that involve multiple database accesses from different parts of the world . OLTP needs a multi-user DBMS s/w to ensure that concurrent transactions operate correctly.

Que 10 - What is database or database management systems (DBMS)? and - What’s the difference between file and database? Can files qualify as a database?
Ans : Database provides a systematic and organized way of storing, managing and retrieving from collection of logically related information.
Secondly the information has to be persistent, that means even after the application is closed the information should be persisted.
Finally it should provide an independent way of accessing data and should not be dependent on the application to access the information.
Main difference between a simple file and database that database has independent way (SQL) of accessing information while simple files do not File meets the storing, managing and retrieving part of a database but not the independent way of accessing data. Many experienced programmers think that the main difference is that file can not provide multi-user capabilities which a DBMS provides. But if we look at some old COBOL and C programs where file where the only means of storing data, we can see functionalities like locking, multi-user etc provided very efficiently. So it’s a matter of debate if some interviewers think this as a main difference between files and database accept it… going in to debate is probably loosing a job.
 
Que 11 - What is SQL ?
Ans : SQL stands for Structured Query Language.SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems. SQL statements are used to retrieve and update data in a database.

Que 12 - What’s difference between DBMS and RDBMS ?
Ans : DBMS provides a systematic and organized way of storing, managing and retrieving from collection of logically related information. RDBMS also provides what DBMS provides but above that it provides relationship integrity. So in short we can say
RDBMS = DBMS + REFERENTIAL INTEGRITY
These relations are defined by using “Foreign Keys” in any RDBMS.Many DBMS companies claimed there DBMS product was a RDBMS compliant, but according to industry rules and regulations if the DBMS fulfills the twelve CODD rules it’s truly a RDBMS. Almost all DBMS (SQL SERVER, ORACLE etc) fulfills all the twelve CODD rules and are considered as truly RDBMS.
 
Que 13 - What are E-R diagrams?
Ans : E-R diagram also termed as Entity-Relationship diagram shows relationship between various tables in the database. .
 
Que 14 - How many types of relationship exist in database designing?
Ans : There are three major relationship models:-
One-to-one
One-to-many
Many-to-many
 
Que 15 - What is normalization? What are different type of normalization?
Ans : There is set of rules that has been established to aid in the design of tables that are meant to be connected through relationships. This set of rules is known as Normalization.
Benefits of Normalizing your database include:
=>Avoiding repetitive entries
=>Reducing required storage space
=>Preventing the need to restructure existing tables to accommodate new data.
=>Increased speed and flexibility of queries, sorts, and summaries.
Following are the three normal forms :-
First Normal Form
For a table to be in first normal form, data must be broken up into the smallest un possible.In addition to breaking data up into the smallest meaningful values, tables first normal form should not contain repetitions groups of fields.
Second Normal form
The second normal form states that each field in a multiple field primary keytable must be directly related to the entire primary key. Or in other words,each non-key field should be a fact about all the fields in the primary key.
Third normal form
A non-key field should not depend on other Non-key field.
 
Que 16 - What is denormalization ?
Ans : Denormalization is the process of putting one fact in numerous places (its vice-versa of normalization).Only one valid reason exists for denormalizing a relational design - to enhance performance.The sacrifice to performance is that you increase redundancy in database.
 
Que 17 - Can you explain Fourth Normal Form and Fifth Normal Form ?
Ans : In fourth normal form it should not contain two or more independent multi-v about an entity and it should satisfy “Third Normal form”.
Fifth normal form deals with reconstructing information from smaller pieces of information. These smaller pieces of information can be maintained with less redundancy.
 
Que 18 - Have you heard about sixth normal form?
Ans : If we want relational system in conjunction with time we use sixth normal form. At this moment SQL Server does not supports it directly.
 
Que 19 : What are DML and DDL statements?
Ans : DML stands for Data Manipulation Statements. They update data values in table. Below are the most important DML statements:-
=>SELECT - gets data from a database table
=> UPDATE - updates data in a table
=> DELETE - deletes data from a database table
=> INSERT INTO - inserts new data into a database table
DDL stands for Data definition Language. They change structure of the database objects like table, index etc. Most important DDL statements are as shown below:-
=>CREATE TABLE - creates a new table in the database.
=>ALTER TABLE – changes table structure in database.
=>DROP TABLE - deletes a table from database
=> CREATE INDEX - creates an index
=> DROP INDEX - deletes an index
 
Que 20 - How do we select distinct values from a table?
Ans : DISTINCT keyword is used to return only distinct values. Below is syntax:- Column age and Table pcdsEmp
SELECT DISTINCT age FROM pcdsEmp
 
Que 21 - What is Like operator for and what are wild cards?
Ans : LIKE operator is used to match patterns. A "%" sign is used to define the pattern.
Below SQL statement will return all words with letter "S"
SELECT * FROM pcdsEmployee WHERE EmpName LIKE 'S%'
Below SQL statement will return all words which end with letter "S"
SELECT * FROM pcdsEmployee WHERE EmpName LIKE '%S'
Below SQL statement will return all words having letter "S" in between
SELECT * FROM pcdsEmployee WHERE EmpName LIKE '%S%'
"_" operator (we can read as “Underscore Operator”). “_” operator is the character defined at that point. In the below sample fired a query Select name from pcdsEmployee where name like '_s%' So all name where second letter is “s” is returned.
 
Que 22 : Can you explain Insert, Update and Delete query?
Ans : Insert statement is used to insert new rows in to table. Update to update existing data in the table. Delete statement to delete a record from the table. Below code snippet for Insert, Update and Delete :-
INSERT INTO pcdsEmployee SET name='rohit',age='24';
UPDATE pcdsEmployee SET age='25' where name='rohit';
DELETE FROM pcdsEmployee WHERE name = 'sonia';
 
Que 23 : What is order by clause?
Ans : ORDER BY clause helps to sort the data in either ascending order to descending order.
Ascending order sort query
SELECT name,age FROM pcdsEmployee ORDER BY age ASC
Descending order sort query
SELECT name FROM pcdsEmployee ORDER BY age DESC
 
Que 24 : What is the SQL " IN " clause?
Ans : SQL IN operator is used to see if the value exists in a group of values. For instance the below SQL checks if the Name is either 'rohit' or 'Anuradha' SELECT * FROM pcdsEmployee WHERE name IN ('Rohit','Anuradha') Also you can specify a not clause with the same. SELECT * FROM pcdsEmployee WHERE age NOT IN (17,16)
 
Que 25 - Can you explain the between clause?
Ans : Below SQL selects employees born between '01/01/1975' AND '01/01/1978' as per mysql
SELECT * FROM pcdsEmployee WHERE DOB BETWEEN '1975-01-01' AND '2011-09-28'
 
Que 26 - we have an employee salary table how do we find the second highest from it?
Ans : below Sql Query find the second highest salary
SELECT * FROM pcdsEmployeeSalary a WHERE (2=(SELECT COUNT(DISTINCT(b.salary)) FROM pcdsEmployeeSalary b WHERE b.salary>=a.salary))
 
Que 27 - What are different types of joins in SQL?
Ans : INNER JOIN
Inner join shows matches only when they exist in both tables. Example in the below SQL there are two tables Customers and Orders and the inner join in made on Customers.Customerid and Orders.Customerid. So this SQL will only give you result with customers who have orders. If the customer does not have order it will not display that record.
SELECT Customers.*, Orders.* FROM Customers INNER JOIN Orders ON Customers.CustomerID =Orders.CustomerID

LEFT OUTER JOIN
Left join will display all records in left table of the SQL statement. In SQL below customers with or without orders will be displayed. Order data for customers without orders appears as NULL values. For example, you want to determine the amount ordered by each customer and you need to see who has not ordered anything as well. You can also see the LEFT OUTER JOIN as a mirror image of the RIGHT OUTER JOIN (Is covered in the next section) if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers LEFT OUTER JOIN Orders ON Customers.CustomerID =Orders.CustomerID

RIGHT OUTER JOIN
Right join will display all records in right table of the SQL statement. In SQL below all orders with or without matching customer records will be displayed. Customer data for orders without customers appears as NULL values. For example, you want to determine if there are any orders in the data with undefined CustomerID values (say, after a conversion or something like it). You can also see the RIGHT OUTER JOIN as a mirror image of the LEFT OUTER JOIN if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers RIGHT OUTER JOIN Orders ON Customers.CustomerID =Orders.CustomerID
 
Que 28 - What is “CROSS JOIN”? or What is Cartesian product?
Ans : “CROSS JOIN” or “CARTESIAN PRODUCT” combines all rows from both tables. Number of rows will be product of the number of rows in each table. In real life scenario I can not imagine where we will want to use a Cartesian product. But there are scenarios where we would like permutation and combination probably Cartesian would be the easiest way to achieve it.
 
Que 29 - How to select the first record in a given set of rows?
Ans : Select top 1 * from sales.salesperson
 
Que 30 - What is the default “-SORT ” order for a SQL?
Ans : ASCENDING
 
Que 31 - What is a self-join?
Ans : If we want to join two instances of the same table we can use self-join.
 
Que 32 - What’s the difference between DELETE and TRUNCATE ?
Ans : Following are difference between them:
=>>DELETE TABLE syntax logs the deletes thus making the delete operations low. TRUNCATE table does not log any information but it logs information about deallocation of data page of the table. So TRUNCATE table is faster as compared to delete table.
=>>DELETE table can have criteria while TRUNCATE can not.
=>> TRUNCATE table can not have triggers.
 
Que 33 - What’s the difference between “UNION” and “UNION ALL” ?
Ans : UNION SQL syntax is used to select information from two tables. But it selects only distinct records from both the table. , while UNION ALL selects all records from both the tables.
 
Que 34 - What are cursors and what are the situations you will use them?
Ans : SQL statements are good for set at a time operation. So it is good at handling set of data. But there are scenarios where we want to update row depending on certain criteria. we will loop through all rows and update data accordingly. There’s where cursors come in to picture.
 
Que 35 - What is " Group by " clause?
Ans : “Group by” clause group similar data so that aggregate values can be derived.
 
Que 36 - What is the difference between “HAVING” and “WHERE” clause?
Ans : “HAVING” clause is used to specify filtering criteria for “GROUP BY”, while “WHERE” clause applies on normal SQL.
 
Que 37 - What is a Sub-Query?
Ans : A query nested inside a SELECT statement is known as a subquery and is an alternative to complex join statements. A subquery combines data from multiple tables and returns results that are inserted into the WHERE condition of the main query. A subquery is always enclosed within parentheses and returns a column. A subquery can also be referred to as an inner query and the main query as an outer query. JOIN gives better performance than a subquery when you have to check for the existence of records.
For example, to retrieve all EmployeeID and CustomerID records from the ORDERS table that have the EmployeeID greater than the average of the EmployeeID field, you can create a nested query, as shown:
SELECT DISTINCT EmployeeID, CustomerID FROM ORDERS WHERE EmployeeID > (SELECT AVG(EmployeeID) FROM ORDERS)
 
Que 38 - What are Aggregate and Scalar Functions?
Ans : Aggregate and Scalar functions are in built function for counting and calculations.
Aggregate functions operate against a group of values but returns only one value.
AVG(column) :- Returns the average value of a column
COUNT(column) :- Returns the number of rows (without a NULL value) of a column
COUNT(*) :- Returns the number of selected rows
MAX(column) :- Returns the highest value of a column
MIN(column) :- Returns the lowest value of a column
Scalar functions operate against a single value and return value on basis of the single value.
UCASE(c) :- Converts a field to upper case
LCASE(c) :- Converts a field to lower case
MID(c,start[,end]) :- Extract characters from a text field
LEN(c) :- Returns the length of a text
 
Que 39 - Can you explain the SELECT INTO Statement?
Ans : SELECT INTO statement is used mostly to create backups. The below SQL backsup the Employee table in to the EmployeeBackUp table. One point to be noted is that the structure of pcdsEmployeeBackup and pcdsEmployee table should be same. SELECT * INTO pcdsEmployeeBackup FROM pcdsEmployee
 
Que 40 - What is a View?
Ans : View is a virtual table which is created on the basis of the result set returned by the select statement.
CREATE VIEW [MyView] AS SELECT * from pcdsEmployee where LastName = 'singh'
In order to query the view
SELECT * FROM [MyView]
 
Que 41 - What is SQl injection ?
Ans : It is a Form of attack on a database-driven Web site in which the attacker executes unauthorized SQL commands by taking advantage of insecure code on a system connected to the Internet, bypassing the firewall. SQL injection attacks are used to steal information from a database from which the data would normally not be available and/or to gain access to an organization’s host computers through the computer that is hosting the database.
SQL injection attacks typically are easy to avoid by ensuring that a system has strong input validation.
As name suggest we inject SQL which can be relatively dangerous for the database. Example this is a simple SQL
SELECT email, passwd, login_id, full_name
FROM members WHERE email = 'x'
Now somebody does not put “x” as the input but puts “x ; DROP TABLE members;”.
So the actual SQL which will execute is :-
SELECT email, passwd, login_id, full_name FROM members WHERE email = 'x' ; DROP TABLE members;
Think what will happen to your database.
 
Que 42 - What is Data Warehousing ?
Ans : Data Warehousing is a process in which the data is stored and accessed from central location and is meant to support some strategic decisions. Data Warehousing is not a requirement for Data mining. But just makes your Data mining process more efficient.
Data warehouse is a collection of integrated, subject-oriented databases designed to support the decision-support functions (DSF), where each unit of data is relevant to some moment in time.
 
Que 43 - What are Data Marts?
Ans : Data Marts are smaller section of Data Warehouses. They help data warehouses collect data. For example your company has lot of branches which are spanned across the globe. Head-office of the company decides to collect data from all these branches for anticipating market. So to achieve this IT department can setup data mart in all branch offices and a central data warehouse where all data will finally reside.
 
Que 44 - What are Fact tables and Dimension Tables ? What is Dimensional Modeling and Star Schema Design
Ans : When we design transactional database we always think in terms of normalizing design to its least form. But when it comes to designing for Data warehouse we think more in terms of denormalizing the database. Data warehousing databases are designed using Dimensional Modeling. Dimensional Modeling uses the existing relational database structure and builds on that.
There are two basic tables in dimensional modeling:-
Fact Tables.
Dimension Tables.
Fact tables are central tables in data warehousing. Fact tables have the actual aggregate values which will be needed in a business process. While dimension tables revolve around fact tables. They describe the attributes of the fact tables.
 
Que 45 - What is Snow Flake Schema design in database? What’s the difference between Star and Snow flake schema?
Ans : Star schema is good when you do not have big tables in data warehousing. But when tables start becoming really huge it is better to denormalize. When you denormalize star schema it is nothing but snow flake design. For instance below customeraddress table is been normalized and is a child table of Customer table. Same holds true for Salesperson table.
 
Que 46 - What is ETL process in Data warehousing? What are the different stages in “Data warehousing”?
Ans : ETL (Extraction, Transformation and Loading) are different stages in Data warehousing. Like when we do software development we follow different stages like requirement gathering, designing, coding and testing. In the similar fashion we have for data warehousing.
Extraction:-
In this process we extract data from the source. In actual scenarios data source can be in many forms EXCEL, ACCESS, Delimited text, CSV (Comma Separated Files) etc. So extraction process handle’s the complexity of understanding the data source and loading it in a structure of data warehouse.
Transformation:-
This process can also be called as cleaning up process. It’s not necessary that after the extraction process data is clean and valid. For instance all the financial figures have NULL values but you want it to be ZERO for better analysis. So you can have some kind of stored procedure which runs through all extracted records and sets the value to zero.
Loading:-
After transformation you are ready to load the information in to your final data warehouse database.
 
Que 47 - What is Data mining ?
Ans : Data mining is a concept by which we can analyze the current data from different perspectives and summarize the information in more useful manner. It’s mostly used either to derive some valuable information from the existing data or to predict sales to increase customer market.
There are two basic aims of Data mining:-
Prediction: -
From the given data we can focus on how the customer or market will perform. For instance we are having a sale of 40000 $ per month in India, if the same product is to be sold with a discount how much sales can the company expect.
Summarization: -
To derive important information to analyze the current business scenario. For example a weekly sales report will give a picture to the top management how we are performing on a weekly basis?
 
Que 48 - Compare Data mining and Data Warehousing ?
Ans : “Data Warehousing” is technical process where we are making our data centralized while “Data mining” is more of business activity which will analyze how good your business is doing or predict how it will do in the future coming times using the current data. As said before “Data Warehousing” is not a need for “Data mining”. It’s good if you are doing “Data mining” on a “Data Warehouse” rather than on an actual production database. “Data Warehousing” is essential when we want to consolidate data from different sources, so it’s like a cleaner and matured data which sits in between the various data sources and brings then in to one format. “Data Warehouses” are normally physical entities which are meant to improve accuracy of “Data mining” process. For example you have 10 companies sending data in different format, so you create one physical database for consolidating all the data from different company sources, while “Data mining” can be a physical model or logical model. You can create a database in “Data mining” which gives you reports of net sales for this year for all companies. This need not be a physical database as such but a simple query.
 
Que 49 - What are indexes? What are B-Trees?
Ans : Index makes your search faster. So defining indexes to your database will make your search faster.Most of the indexing fundamentals use “B-Tree” or “Balanced-Tree” principle. It’s not a principle that is something is created by SQL Server or ORACLE but is a mathematical derived fundamental.In order that “B-tree” fundamental work properly both of the sides should be balanced.
 
Que 50 - I have a table which has lot of inserts, is it a good database design to create indexes on that table?
Insert’s are slower on tables which have indexes, justify it?or Why do page splitting happen?
Ans : All indexing fundamentals in database use “B-tree” fundamental. Now whenever there is new data inserted or deleted the tree tries to become unbalance.
Creates a new page to balance the tree.
Shuffle and move the data to pages.
So if your table is having heavy inserts that means it’s transactional, then you can visualize the amount of splits it will be doing. This will not only increase insert time but will also upset the end-user who is sitting on the screen. So when you forecast that a table has lot of inserts it’s not a good idea to create indexes.

Tuesday, September 17, 2013

Some Questions & Answers about C / C++ / JAVA part 2..


Que 16 - What is reference ??
Answer : Reference is a name that acts as an alias, or alternative name, for a previously defined variable or an object.
prepending variable with "&" symbol makes it as reference.
For Example:
int a;
int &b = a; 
Que 17 - What is passing by reference??
Answer : Method of passing arguments to a function which takes parameter of type reference.
For Example:
void swap( int & x, int & y )
{
      int temp = x;
      x = y;
      y = temp; 
}
int a=2, b=3;
swap( a, b );
Basically, inside the function there won't be any copy of the arguments "x" and "y" instead they refer to original variables a and b. so no extra memory needed to pass arguments and it is more efficient. 

Que 18 - When do use "const" reference arguments in function??
Answer :
a) Using const protects you against programming errors that inadvertently alter data.
b) Using const allows function to process both const and non-const actual arguments, while a function without const in the prototype can only accept non constant arguments.
c) Using a const reference allows the function to generate and use a temporary variable appropriately.
Que 19 - When are temporary variables created by C++ compiler??
Answer : Provided that function parameter is a "const reference", compiler generates temporary variable in following 2 ways.
a) The actual argument is the correct type, but it isn't Lvalue
For Example :
double Cube(const double & num)
{
     num = num * num * num;
     return num;
}
double temp = 2.0;
double value = cube(3.0 + temp); // argument is a expression and not a Lvalue;

b) The actual argument is of the wrong type, but of a type that can be converted to the correct type
For Example:
long temp = 3L;
double value = cuberoot ( temp); // long to double conversion 

Que 20 - What is virtual function??
Answer : When derived class overrides the base class method by redefining the same function, then if client wants to access redefined the method from derived class through a pointer from base class object, then you must define this function in base class as virtual function.
For Example :
class parent
{
   void Show() 
  { 
      cout << "i'm parent" << endl;
   }
};
class child: public parent
{
   void Show() 
  { 
      cout << "i'm child" << endl;
  }
};
parent * parent_object_ptr = new child;
parent_object_ptr->show() // calls parent->show() i 

now we goto virtual world...
class parent
{
   virtual void Show() 
  { 
      cout << "i'm parent" << endl;
   }
};
class child: public parent
{
   void Show() 
   { 
      cout << "i'm child" << endl;
    }
};
parent * parent_object_ptr = new child;
parent_object_ptr->show() // calls child->show()  

Que 21 - What is pure virtual function? or what is abstract class??
Answer : When you define only function prototype in a base class without implementation and do the complete implementation in derived class. This base class is called abstract class and client won't able to instantiate an object using this base class.
You can make a pure virtual function or abstract class this way..
For Example :
class Boo
{
     void foo() = 0;
}
Boo MyBoo; // compilation error
Que 22 - What is Memory alignment??
Answer : The term alignment primarily means the tendency of an address pointer value to be a multiple of some power of two. So a pointer with two byte alignment has a zero in the least significant bit. And a pointer with four byte alignment has a zero in both the two least significant bits. And so on. More alignment means a longer sequence of zero bits in the lowest bits of a pointer.

Que 23 - What problem does the namespace feature solve??
Answer : Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature surrounds a library's external declarations with a unique namespace that eliminates the potential for those collisions.
namespace [identifier] { namespace-body }
A namespace declaration identifies and assigns a name to a declarative region.
The identifier in a namespace declaration must be unique in the declarative region in which it is used. The identifier is the name of the namespace and is used to reference its members.

Que 24 - What is the use of 'using' declaration??
Answer : A using declaration makes it possible to use a name from a namespace without the scope operator. 

Que 25 - What is an Iterator class??
Answer : A class that is used to traverse through the objects maintained by a container class. There are five categories of iterators: input iterators, output iterators, forward iterators, bidirectional iterators, random access. An iterator is an entity that gives access to the contents of a container object without violating encapsulation constraints. Access to the contents is granted on a one-at-a-time basis in order. The order can be storage order (as in lists and queues) or some arbitrary order (as in array indices) or according to some ordering relation (as in an ordered binary tree). The iterator is a construct, which provides an interface that, when called, yields either the next element in the container, or some value denoting the fact that there are no more elements to examine. Iterators hide the details of access to and update of the elements of a container class. Something like a pointer. 

Que 26 - What is a dangling pointer??
Answer : A dangling pointer arises when you use the address of an object after its lifetime is over. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.

Que 27 - What do you mean by Stack unwinding??
Answer : It is a process during exception handling when the destructor is called for all local objects in the stack between the place where the exception was thrown and where it is caught.

Que 28 - Name the operators that cannot be overloaded??
Answer : sizeof, ., .*, .->, ::, ?: 

Que 29 - What is a container class? What are the types of container classes??
Answer : A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container. 

Que 30 - What is inline function??
Answer : The __inline keyword tells the compiler to substitute the code within the function definition for every instance of a function call. However, substitution occurs only at the compiler's discretion. For example, the compiler does not inline a function if its address is taken or if it is too large to inline.

Que 31 - What is overloading??
Answer : With the C++ language, you can overload functions and operators. Overloading is the practice of supplying more than one definition for a given function name in the same scope.
- Any two functions in a set of overloaded functions must have different argument lists.
- Overloading functions with argument lists of the same types, based on return type alone, is an error. 

Que 32 - What is Overriding??
Answer : To override a method, a subclass of the class that originally declared the method must declare a method with the same name, return type (or a subclass of that return type), and same parameter list.
The definition of the method overriding is: 
· Must have same method name.  
· Must have same data type.  
· Must have same argument list.  
Overriding a method means that replacing a method functionality in child class. To imply overriding functionality we need parent and child classes. In the child class you define the same method signature as one defined in the parent class.

Que 33 - What is "this" pointer?
Answer : The this pointer is a pointer accessible only within the member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer.
When a nonstatic member function is called for an object, the address of the object is passed as a hidden argument to the function. For example, the following function call
For Example :
myDate.setMonth( 3 );
can be interpreted this way:
setMonth( &myDate, 3 );
The object's address is available from within the member function as the this pointer. It is legal, though unnecessary, to use the this pointer when referring to members of the class.

Que 34 - What happens when you make call "delete this;" ??
Answer : The code has two built-in pitfalls. First, if it executes in a member function for an extern, static, or automatic object, the program will probably crash as soon as the delete statement executes. There is no portable way for an object to tell that it was instantiated on the heap, so the class cannot assert that its object is properly instantiated. Second, when an object commits suicide this way, the using program might not know about its demise. As far as the instantiating program is concerned, the object remains in scope and continues to exist even though the object did itself in. Subsequent dereferencing of the pointer can and usually does lead to disaster.
You should never do this. Since compiler does not know whether the object was allocated on the stack or on the heap, "delete this" could cause a disaster.

Que 35 - How virtual functions are implemented C++??
Answer : Virtual functions are implemented using a table of function pointers, called the vtable.  There is one entry in the table per virtual function in the class.  This table is created by the constructor of the class.  When a derived class is constructed, its base class is constructed first which creates the vtable.  If the derived class overrides any of the base classes virtual functions, those entries in the vtable are overwritten by the derived class constructor.  This is why you should never call virtual functions from a constructor: because the vtable entries for the object may not have been set up by the derived class constructor yet, so you might end up calling base class implementations of those virtual functions

Que 36 - What is name mangling in C++??
Answer : The process of encoding the parameter types with the function/method name into a unique name is called name mangling. The inverse process is called demangling.
For example :
 Foo::bar(int, long) const is mangled as `bar__C3Fooil'. 
For a constructor, the method name is left out. That is Foo::Foo(int, long) const is mangled as `__C3Fooil'.

Que 37 - What is the difference between a pointer and a reference??
Answer : A reference must always refer to some object and, therefore, must always be initialized; pointers do not have such restrictions. A pointer can be reassigned to point to different objects while a reference always refers to an object with which it was initialized.

Que 38 - How are prefix and postfix versions of operator++() differentiated??
Answer : The postfix version of operator++() has a dummy parameter of type int. The prefix version does not have dummy parameter.

Que 39 - What is the difference between const char *myPointer and char *const myPointer??
Answer : Const char *myPointer is a non constant pointer to constant data; while char *const myPointer is a constant pointer to non constant data.

Que 40 - How can I handle a constructor that fails?
Answer : throw an exception. Constructors don't have a return type, so it's not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception.

Que 41 - How can I handle a destructor that fails??
Answer : Write a message to a log-file. But do not throw an exception. 
The C++ rule is that you must never throw an exception from a destructor that is being called during the "stack unwinding" process of another exception. For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get popped. This is called stack unwinding. 
During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a } catch (Bar e) { handler? There is no good answer -- either choice loses information. 
So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you're dead. 

Que 42 - What is Virtual Destructor??
Answer : Using virtual destructors, you can destroy objects without knowing their type - the correct destructor for the object is invoked using the virtual function mechanism. Note that destructors can also be declared as pure virtual functions for abstract classes.
if someone will derive from your class, and if someone will say "new Derived", where "Derived" is derived from your class, and if someone will say delete p, where the actual object's type is "Derived" but the pointer p's type is your class.
Que 43 - Can you think of a situation where your program would crash without reaching the breakpoint which you set at the beginning of main()??
Answer : C++ allows for dynamic initialization of global variables before main() is invoked. It is possible that initialization of global will invoke some function. If this function crashes the crash will occur before main() is entered. 
Name two cases where you MUST use initialization list as opposed to assignment in constructors.
Both non-static const data members and reference data members cannot be assigned values; instead, you should use initialization list to initialize them. 

Que 44 - Can you overload a function based only on whether a parameter is a value or a reference??
Answer : No. Passing by value and by reference looks identical to the caller. 

Que 45 - What are the differences between a C++ struct and C++ class??
Answer : The default member and base class access specifiers are different.
The C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base class inheritance, and a class defaults to the private access specifier and private base class inheritance. 

Que 46 - What does extern "C" int func(int *, Foo) accomplish??
Answer : It will turn off "name mangling" for func so that one can link to code compiled by a C compiler. 

Que 47 - How do you access the static member of a class?
Answer : <ClassName>::<StaticMemberName>

Que 48 - What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages??
Answer : Multiple Inheritance is the process whereby a child can be derived from more than one parent class. The advantage of multiple inheritance is that it allows a class to inherit the functionality of more than one base class thus allowing for modeling of complex relationships. The disadvantage of multiple inheritance is that it can lead to a lot of confusion(ambiguity) when two base classes implement a method with the same name.

Que 49 - What are the access privileges in C++? What is the default access level??
Answer : The access privileges in C++ are private, public and protected. The default access level assigned to members of a class is private. Private members of a class are accessible only within the class and by friends of the class. Protected members are accessible by the class itself and it's sub-classes. Public members of a class can be accessed by anyone.

Que 50 - Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?? 
Answer : No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.

Popular Posts