Saturday 21 December 2013

Android important interview question and answers

Android important technical interview question and answer.

These are the basic questions which every interviewer ask from android candidate.
Learn android tutorials from techlovejump.

What is Activity .

An activity represents a single screen with a user interface. For example, an email app might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails

What is Service.

A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different app, or it might fetch data over the network without blocking user interaction with an activity. Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it.


What are Content providers.

A content provider manages a shared set of app data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your app can access. Through the content provider, other apps can query or even modify the data (if the content provider allows it). For example, the Android system provides a content provider that manages the user's contact information. 

What are Broadcast receivers.





A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Apps can also initiate broadcasts—for example, to let other apps know that some data has been downloaded to the device and is available for them to use.


Difference between Explicit Intent and Implicit Intent.

There are two types of intents:
Explicit intents specify the component to start by name (the fully-qualified class name). You'll typically use an explicit intent to start a component in your own app, because you know the class name of the activity or service you want to start. For example, start a new activity in response to a user action or start a service to download a file in the background.
Implicit intents do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it. For example, if you want to show the user a location on a map, you can use an implicit intent to request that another capable app show a specified location on a map.

To learn about android tutorials visit

Saturday 2 November 2013

cloud computing interview questions

Cloud computing interview questions

Does network topology play an important role in deciding the success of a Cloud Infrastructure?
The network topology plays a vital role in selecting a cloud model and success of that model
Public Cloud 
These are the platforms which are public means open to the people for use and deployment. For example, google, amazon etc. They focus on a few layers like cloud application, infrastructure providing and providing platform markets.
Private Cloud
Organizations choose to build their private cloud as to keep the strategic, operation and other reasons to themselves and they feel more secure to do it.
Hybrid Clouds
It is the combination of public and private cloud. It is the most robust approach to implement cloud architecture as it includes the functionalities and features of both the worlds.
Learn android google cloud messaging tutorial.


2.   What are the different layers of cloud computing?
Cloud computing consists of 3 layers in the hierarchy and these are as follows:
1. Infrastructure as a Service (IaaS) provides cloud infrastructure in terms of hardware like memory, processor speed etc.
2. Platform as a Service (PaaS) provides cloud application platform for the developers.
3. Software as a Service (SaaS) provides cloud applications which are used by the user directly without installing anything on the system. The application remains on the cloud and it can be saved and edited in there only.
3.   What resources are provided by infrastructure as a service?
Infrastructure as a Service provides physical and virtual resources that are used to build a cloud. Infrastructure deals with the complexities of maintaining and deploying of the services provided by this layer. The infrastructure here is the servers, storage and other hardware systems.
4.   How important is platform as a service?
Platform as a Service is an important layer in cloud architecture. It is built on the infrastructure model, which provides resources like computers, storage and network. This layer includes organizing and operate the resources provided by the below layer. It is also responsible to provide complete virtualization of the infrastructure layer to make it look like a single server and keep it hidden from the outside world.
5.   What does software as a service provide?
Software as Service is another layer of cloud computing, which provides cloud applications like google is doing, it is providing google docs for the user to save their documents on the cloud and create as well. It provides the applications to be created on fly without adding or installing any extra software component. It provides built in software to create wide varieties of applications and documents and share it with other people online.
6.   What are the different deployment models?
Cloud computing supports many deployment models and they are as follows:
- Private Cloud
Organizations choose to build there private cloud as to keep the strategic, operation and other reasons to themselves and they feel more secure to do it. It is a complete platform which is fully functional and can be owned, operated and restricted to only an organization or an industry. More organizations have moved to private clouds due to security concerns. Virtual private cloud is being used that operate by a hosting company.
- Public Cloud 
These are the platforms which are public means open to the people for use and deployment. For example, google, amazon etc. They focus on a few layers like cloud application, infrastructure providing and providing platform markets.
- Hybrid Clouds
It is the combination of public and private cloud. It is the most robust approach to implement cloud architecture as it includes the functionalities and features of both the worlds. It allows organizations to create their own cloud and allow them to give the control over to someone else as well.
7.   What essential things a user should know before going for cloud computing platform?
A user should know some parameters by which he can go for the cloud computing services. The parameters are as follows:
1. User should know the data integrity in cloud computing: It is a measure to ensure integrity like the data is accurate, complete and reasonable.
2. Compliance: user should make sure that proper rules and regulations are followed while implementing the structure.
3. Loss of data: user should know about the provisions that are provided in case of loss of data so that backup and recovery can be possible.
4. Business continuity plans: user should think about does the cloud services provide him uninterrupted data resources.
5. Uptime: user should know about the uptime the cloud computing platform provides and how helpful it is for the business.
6. Data storage costs: user should find out about the cost which you have to pay before you go for cloud computing.


8.   What is Hypervisor in Cloud Computing and its types?
The hypervisor is a virtual machine monitor (VMM) that manages resources for virtual machines. The name hypervisor is suggested as it is a supervisory tool for the virtual machines. There are mainly two types of hypervisors :
Type-1: the guest Vm runs directly over the host hardware, e.g Xen, Hyper-V, VmWare ESXi
Type-2: the guest Vm runs over hardware through a host OS, e.g Kvm, Oracle virtualbox

9.   What do you understand from VPN?
VPN stands for virtual private network; it is a private cloud which manages the security of the data during the transport in the cloud environment. VPN allows an organization to make a public network as private network and use it to transfer files and other resources on a network.

10.                What does a VPN consists of?
VPN is known as virtual private network and it consists of two important things:
1. Firewall: it acts as a barrier between the public network and any private network. It filters the messages that are getting exchanged between the networks. It also protects from any malicious activity being done on the network.
2. Encryption: it is used to protect the sensitive data from professional hackers and other spammers who are usually remain active to get the data. With a message always there will be a key with which you can match the key provided to you.

11.                What is the requirement of virtualization platforms in implementing cloud?
Virtualization is the basis of the cloud computing and there are many platforms that are available like VMware is a technology that provides the provision to create private cloud and provide a bridge to connect external cloud with private cloud. There are three key features that have to be identified to make a private cloud that is:
- Cloud operating system.
- Manage the Service level policies
- Virtualization keeps the user level and the backend level concepts different from each other so that a seamless environment can be created between both.

12.                What is the use of eucalyptus in cloud computing environment?
Eucalyptus stands for Elastic Utility Computing Architecture for Linking Your Programs to Useful Systems and provides an open source software infrastructure to implement clusters in cloud computing platform. It is used to build private, public and hybrid clouds. It can also produce your own datacenter into a private cloud and allow you to extend the functionality to many other organizations. Eucalyptus provides APIs to be used with the web services to cope up with the demand of resources used in the private clouds.
13.                Is there any difference in cloud computing and computing for mobiles?
Mobile cloud computing uses the same concept but it just adds a device of mobile. Cloud computing comes in action when a task or a data get kept on the internet rather than individual devices. It provides users on demand access to the data which they have to retrieve. Applications run on the remote server, and then given to the user to be able to, store and manage it from the mobile platform.
14.                 

15.                Are Type-1 Hypervisors better in performance than Type-2 Hypervisors and Why?
Yes the Type-1 Hypervisors are better in performance as compared to Type-2 hypervisors because Type-1 hypervisors does not run through a host OS, they utilize all resources directly from Host hardware. In cloud implementation Type-1 hypervisors are used rather than Type-2 because Cloud servers need to run multiple OS images and it should be noted that if OS images are run on host a OS as in case of Type-2, the resources will get wasted.
16.                What are the characteristics on which a Cloud Computing Model should be selected for implementing and managing workload?
Scalability is a characteristic of cloud computing through which increasing workload can be handled by increasing in proportion the amount of resource capacity. It allows the architecture to provide on demand resources if the requirement is being raised by the traffic. Whereas, elasticity is being one of the characteristic provide the concept of commissioning and decommissioning of large amount of resource capacity dynamically. It is measured by the speed by which the resources are coming on demand and the usage of the resources.
17.                What is the minimal requirement to implement an IAAS Cloud?
The minimal requirement to implement are basically three things:
 OS to support hypervisor or a hypervisor. 
- Preferably open-source software like Linux and Xen hypervisor
Networking topology and implementation.
- Public Network or Private network with Level 3 Switch
Selection of cloud model as per requirement or business.
- SaaS, Software as a Service
- PaaS, Platform as a Service
- CaaS, Communication as a Service
18.                How is the Cloud Computing different from primitive Client-Server Architecture?
The primitive Client-Server architecture is a one-to-one communication between only two physical machines namely Client machine and Server machine (datacenter). Whereas the cloud computing, infrastructure is similar at the client side but varies at server-side. The server-side contains a main Cloud Controller that forwards the request to its worker machines known as Nodes. These nodes are a grid computing machines that dedicate all its resources to process application. These nodes are maintained in clusters. So a cloud computing infrastructure is quite complicated on server side that processes all the requests from clients and send the result back.
19.                Why should one prefer public cloud over private cloud?
The cloud technology is the best example of sustainable technology that utilizes all the computing resources. If a person needs to setup a quick business and wants to host its website, he need not require to setup a full-fledged private cloud. Rather he should go for public cloud hosting that provides different pay-per-use subscriptions, which could actually result in being economical. There are numbers of vendors that provide such services like godaddy.com etc.
20.                Is it cost effective to implement a private cloud rather than a public cloud and why?
It depends on the type of business that demands a cloud setup. Suppose if the subscription on a public cloud for an application that is to be deployed on OS images is proving to be more costly then to buy some new datacenters and maintain them. Then obviously the a private cloud has to be setup instead of a public cloud. This public clouds follow utility billing methodology as electricity bill for example.
21.                Is Cloud computing an application?
The Cloud Computing is not an application but it is a methodology that deploys application in a custom fashion on a server. It can be also learned as an advance model of client-server architecture that is highly flexible, scalable and configurable. This architecture leverages high performance out of machines with quite an ease of management.
22.                What do you understand by CaaS?
CaaS is a terminology given in telecom industry as Communication as a Service. The Voice-over-Ip (VoIP) follows a same delivery model. CaaS can offer the enterprise user features such as desktop call control, presence, unified messaging, and desktop faxing. In addition to the enterprise features, CaaS also has a set of services for contact center automation that includes IVR, ACD, call recording, multimedia routing (e-mail and text chat), and screen pop integration.
23.                How does cloud computing provides on-demand functionality?
Cloud computing is a metaphor used for internet. It provides on-demand access to virtualized IT resources that can be shared by others or subscribed by you. It provides an easy way to provide configurable resources by taking it from a shared pool. The pool consists of networks, servers, storage, applications and services.
24.                What is the difference between scalability and elasticity?
Scalability is a characteristic of cloud computing through which increasing workload can be handled by increasing in proportion the amount of resource capacity. It allows the architecture to provide on demand resources if the requirement is being raised by the traffic. Whereas, elasticity is being one of the characteristic provide the concept of commissioning and decommissioning of large amount of resource capacity dynamically. It is measured by the speed by which the resources are coming on demand and the usage of the resources.
25.                What are the different datacenters deployed for this?
Cloud computing is made up of various datacenters put together in a grid form. It consists of different datacenters like:
- Containerized Datacenters
These are the traditional datacenters that allow high level of customization with servers, mainframe and other resources. It requires planning, cooling, networking and power to access and work.
- Low-Density Datacenters
These datacenters are optimized to give high performance. In these datacenters the space constraint is being removed and there is an increased density. It has a drawback that with high density the heat issue also creeps in. These datacenters are very much suitable to develop the cloud infrastructure.
26.                What is the use of API in cloud services?
API stands for Application programming interface is very useful in cloud platforms as it allows easy implementation of it on the system. It removes the need to write full fledged programs. It provides the instructions to make the communication between one or more applications. It also allows easy to create application with ease and link the cloud services with other systems.
27.                What are the different modes of software as a service?
Software as a Service provides cloud application platform on which user can create application with the tools provided. The modes of software as a service are defined as:
1. Simple multi-tenancy: in this each user has its own resources that are different from other users. It is an inefficient mode where the user has to put more time and money to add more infrastructure if the demand rises in less time to deliver.
2. Fine grain multi-tenancy: in this the functionality remains the same that the resources can be shared to many. But it is more efficient as the resources are shared not the data and permission within an application.
28.                What is the difference between traditional datacenters and cloud?
Cloud computing uses the concept of datacenter as it is the datacenter is based on the tradition one so the difference between them are as follows:
- Cost of the traditional datacenter is higher, due to heating issues and other hardware/software related issues but this is not the case with the cloud computing infrastructure.
- It gets scaled when the demand increases. Most of the cost is being spent on the maintenance being performed on the datacenters, whereas cloud platform requires minimum maintenance and not very expert hand to handle them.
29.                What are the three cost factors involves in cloud data center?
Cloud data center doesn't require experts to operate it, but it requires skilled people to see the maintenance, maintain the workloads and to keep the track of the traffic. The labor cost is 6% of the total cost to operate the cloud data center. Power distribution and cooling of the datacenter cost 20% of the total cost. Computing cost is at the end and is the highest as it is where lots of resources and installation has to be done. It costs the maximum left percentage.
30.                What are different data types used in cloud computing?
Cloud computing is going all together for a different look as it now includes different data types like emails, contracts, images, blogs, etc. The amount of data increasing day by day and cloud computing is requiring new and efficient data types to store them. For example if you want to save video then you need a data type to save that. Latency requirements are increasing as the demand is increasing. Companies are going for lower latency for many applications.
31.                What are some open source cloud computing platform databases?
Cloud computing platform has various databases that are in support. The open source databases that are developed to support it is as follows:
1. MongoDB: is an open source database system which is schema free and document oriented database. It is written in C++ and provides tables and high storage space.
2. CouchDB: is an open source database system based on Apache server and used to store the data efficiently
3. LucidDB: is the database made in Java/C++ for data warehousing. It provides features and functionalities to maintain data warehouse.
32.                How to secure your data for transport in cloud?
Cloud computing provides very good and easy to use feature to an organization, but at the same time it brings lots of question that how secure is the data, which has to be transported from one place to another in cloud. So, to make sure it remains secure when it moves from point A to point B in cloud, check that there is no data leak with the encryption key implemented with the data you sending.
33.                What is the security aspects provided with cloud?
Security is one of the major aspects which come with any application and service used by the user. Companies or organizations remain much more concerned with the security provided with the cloud. There are many levels of security which has to be provided within cloud environment such as:
- Identity management: it authorizes the application service or hardware component to be used by authorized users.
- Access control: permissions has to be provided to the users so that they can control the access of other users who are entering the in the cloud environment.
- Authorization and authentication: provision should be made to allow the authorized and authenticated people only to access and change the applications and data.
34.                How the cloud services are measured?
Cloud computing provides the services to the organizations so they can run their applications and install them on the cloud. Virtualization is used to deploy the cloud computing models as it provides a hidden layer between the user and the physical layer of the system. The cloud services are measured in terms of use. Pay as much as you use that can be on the basis of hours or months or years. Cloud services allow users to pay for only what they use and according to the demand the charges or the prices gets increased.
35.                What are the optimizing strategies used in cloud?
To optimize the cost and other resources there is a concept of three-data-center which provides backups in cases of disaster recovery and allows you to keep all the data intact in the case of any failure within the system. System management can be done more efficiently by carrying out pre-emptive tasks on the services and the processes which are running for the job. Security can be more advanced to allow only the limited users to access the services.
36.                What are the security laws which take care of the data in the cloud?
The security laws which are implements to secure data in the cloud are as follows: Input validation: controls the input data which is being to any system. Processing: control that the data is being processed correctly and completely in an application. File: control the data being manipulated in any type of file. Output reconciliation: control the data that has to be reconciled from input to output. Backup and recovery: control the security breaches logs and the problems which has occurred while creating the back.
37.                Name few platforms which are used for large scale cloud computing
There are many platforms available for cloud computing but to model the large scale distributed computing the platforms are as follows:
1. MapReduce: is software that is being built by Google to support distributed computing. It is a framework that works on large set of data. It utilizes the cloud resources and distributes the data to several other computers known as clusters. It has the capability to deal with both structured and non-structured data.
2. Apache Hadoop: is an open source distributed computing platform. It is being written in Java. It creates a pool of computer each with hadoop file system. It then clusters the data elements and applies the hash algorithms that are similar. Then it creates copy of the files that already exist.
38.                What are some examples of large cloud providers and their databases?
Cloud computing has many providers and it is supported on the large scale. The providers with their databases are as follows:
- Google bigtable: it is a hybrid cloud that consists of a big table that is spilt into tables and rows. MapReduce is used for modifying and generating the data.
- Amazon SimpleDB: is a webservice that is used for indexing and querying the data. It allows the storing, processing and creating query on the data set within the cloud platform. It has a system that automatically indexes the data.
- Cloud based SQL: is introduced by Microsoft and it is based on SQL database. it provides data storage by the usage of relational model in the cloud. The data can be accessed from the cloud using the client application.

List of top interview questions on cloud computing.



Friday 1 November 2013

How to get a job in software company

Being in Final year You should concentrate first on your Academics to Successfully complete it and It is very good that you like to work in Top Software Companies,
I here give you some instructions that will help you to enter into the Best Software Companies.

First of All you should know what Software Companies need from a Candidate and their Selection Process.

You will have the written Exam,Technical Interview and HR Interview as the Selection Process in most of the Companies.

Written Test 

Written Most have Multiple Choice Questions from your Subject and Most of the Questions from Numerical Aptitude Vocabularies etc
So Start Studying the Aptitude questions from now onwards,
Better You buy a Book and See the examples and try to solve the excerise Questions by your own attempt.This will help you to get Success in Written Exams.

Group Discussion:
In this stage You will need to show your Individuality to get the favour of the Recruiters,Good Communication Skills will help you to Show up in Group Discussion. 

Technical Interview 

In technical Interview You will have the Questions from the subjects you learnt.

HR Interview:

It will be Just like Tell about You and Discussion about Salary Package etc.

Just trust god. He will surely help you. One day will come and on that day all interview rounds will be cleared.
Hurray !!
 :)
If you have any comments then please post it  /
cheers !!

Friday 25 October 2013

amcat question papers 1

amcat placement paper.amcat interview questions.amcat question papers.



ENGLISH COMPREHENSION: Sample Questions

All questions are Multiple-Choice-Questions with only one option as the correct answer.

In the following question select the word which is OPPOSITE in the meaning of the given word.

Q1. INDISCREET

a. reliable
b. honest
c. prudent
d. stupid


Q2. SOLICITUDE

a. insouciance
b. ingenuity
c. propriety
d. austerity

Q3. In the sentence there is a bold word or phrase. One of the words or phrases given in the options conveys almost the same meaning as the bold word or phrase in the sentence. Select that option which is nearest in meaning.

It is preposterous on your part to look for a job without first completing your education.

a. Wise
b. Imperative
c. Advisable
d. Most admirable
e. Very absurd

In the following questiones, fill in the blank space.

Q4. The success that he has gained, though striking enough, does not, however, commensurate . . . . the efforts made by him.

a. About
b. From
c. With
d. Beside
e. Over

Q5. Vinod took his meals after he . . . .

a. Had completed his work
b. Had been completing his work
c. Was completing his work
d. Had been completed his work
e. Had got completed his work

In the following questions, select the word or phrase that is similar in meaning to the given word.

Q6. Nonchalance

a. Neutrality
b. Indifference
c. All-knowing
d. Ignorance
e. Untimeliness

Q7. Conceal

a. Hide
b. Seal
c. Ceiling
d. Horrifying

Q8. Read the sentence to find out whether there is any grammatical error in it. The error, if any, will be in one part of the sentence. The letter of that part is the answer. If there is no error, the answer is 'D'. (Ignore - the errors of punctuation,if any)

(A) The whole thing moves/ (B) around the concept of building a small dynamic/(C) organisation into a larger one./(D) No error.

a. (A)
b. (B)
c. (C )
d. (D)

Q9. In the question a part of the sentence is italicised. Alternatives to the italicised part is given which may improve the sentence. Choose the correct alternative. In case no improvement is needed. Option 'D' is the answer.

She gave most of her time to music.

a. spent
b. lent
c. devoted
d. No improvement

Q10. The given sentences when properly sequenced, form a coherent paragraph. Each sentence is labelled with a number. Choose the most logical order of sentences from among the four given choices to construct a coherent paragraph.

1. He was so busy with them that he did not get time to eat. 2. Thousands of people came to him and asked different types of questions. 3. No one cared to see that he had his food or rest that night. 4. Swami Vivekanand once stayed in a small village.

a. 2341
b. 3214
c. 4213
d. 4231

Answer the question based on the given passage

Management is a set of processes that can keep a complicated system of people and technology running smoothly. The most important aspects of management include planning, budgeting, organising, staffing, controlling, and problem-solving. Leadership is a set of processes that creates organisations in the first place or adapts them to significantly changing circumstances. Leadership defines what the future should look like, aligns people with that vision, and inspires them to make it happen despite the obstacles. This distinction is absolutely crucial for our purposes here: Successful transformation is 70 to 90 per cent leadership and only 10 to 30 percent management. Yet for historical reasons, many organisations today don't have much leadership. And almost everyone thinks about the problem here as one of managing change. For most of this country, as we created thousands and thousands of large organisations for the first time in human history, we didn't have enough good managers to keep all those bureaucracies functioning. So many companies and universities developed management programs and hundreds and thousands of people were encouraged to learn management on the job. And they did. But, people were taught little about leadership. To some degree, management was emphasised because it's easier to teach than leadership. But even more so, management was the main item on the twentieth-century agenda because that's what was needed. For every entrepreneur or business builder who was a leader, we needed hundreds of managers to run their ever-growing enterprises. Unfortunately for us today, this emphasis on management has often been institutionalised in corporate cultures that discourage employees from learning how to lead. Ironically, past success is usually the key ingredient in producing this outcome. The syndrome, as I have observed it on many occasions, goes like this: success creates some degree of marked dominance which in turn produces much growth. After a while keeping the ever-larger organisation under control becomes the primary challenge. So attention turns inward and managerial competencies are nurtured. With a strong emphasis on management but not leadership, bureaucracy and an inward focus takeover. But with continued success, the result mostly of market dominance, the problem often goes unaddressed and an unhealthy arrogance begins to evolve. All of these characteristics then make any transformation effort much more difficult. Arrogant managers can over-evaluate their current performance and competitive position, listen poorly and learn slowly. Inwardly focused employees can have difficulty seeing the very forces that present threats and opportunities. Bureaucratic cultures can smother those who want to respond to shifting conditions. And the lack of leadership leaves no force inside these organisations to break out of the morass.

Q11. Why did companies and universities develop programmes to prepare managers in such a large number?

a. (A) Companies and universities wanted to generate funds through these programmes
b. (B) The large number of organisations were created as they needed managers in good number
c. (C) Organisations did not want to spend their scarce resources in training managers
d. (D) Organisations wanted to create communication network through trained managers

Q12. How has the author defined management?

a. It is the process of adapting organisations to changing circumstances.
b. It is the system of aligning people with the direction it has taken.
c. It refers to creating a vision to help direct the change effectively.
d. Creating better performance through customer orientation.

Q13. What is the historical reason for many organisations not having leadership?

a. A view that leaders are born, they are not made
b. Leaders lack managerial skills and organisations need managers
c. Leaders are weak in carrying out traditional functions of management
d. Leaders allow too much complacency in organisations

Q14. Which of the following characteristics help organisations in their transformation efforts?

a. Emphasis on leadership but not management
b. A strong and dogmatic culture
c. Bureaucratic and inward looking approach
d. Failing to acknowledge the value of customers and shareholders

Q15. Which of the following is similar in meaning of the word 'smother' as used in the passage?

a. Suppress
b. Encourage
c. Instigate
d. Criticise


amcat question papers 2

amcat placement paper.amcat interview questions.amcat question papers.


LOGICAL ABILITY: Sample Questions

All questions are Multiple-Choice-Questions with only one option as the correct answer.

Q1. The question shows a pair of words in which the first is related to the second in some way. It is followed by a single word which bears a similar relation to one of the given alternatives. Find the correct alternative to complete the analogy.

Melt:Liquid::Freeze: ?

a. Ice
b. Condense
c. Solid
d. Crystal

Q2. Fill in the blankGuilt is to Past as Hope is to ......

a. Present
b. Future
c. Today
d. Despair
e. Hopeless

Q3. From the given choices select the odd man out:

a. Bird
b. Kite
c. Crow
d. Pigeon
e. Sparrow

Q4. Find the missing pattern

BOQD : ERTG :: ANPC : ?

a. DQSF
b. FSHU
c. SHFU
d. DSQF

Q5. Find the missing number

5 : 24 :: 8 : ?

a. 65
b. 63
c. 62
d. 64

Q6. From the given choices select the odd man out

a. DFHEG
b. TWXUV
c. OQSPR
d. JLNKM


Q7. If HARD is coded as 1357 and SOFT is coded as 2468, what will 21448 stand for?

a. SHAFT
b. SHORT
c. SHOOT
d. SHART

Q8. Find the next number in the series

1, 6, 13, 22, 33, ......

a. 44
b. 45
c. 46
d. 47

Q9. The question contains some statements followed by some conclusions. Decide which of the given conclusions logically follow from the given statements, disregarding commonly known facts.

Statements:
I) All tomatoes are red.
II) All grapes are tomatoes.
Conclusions:
I) All grapes are red.
II) Some Tomatoes are grapes.

a. Only conclusion I follows.
b. Only conclusion II follows.
c. Neither I nor II follows
d. Both I and II follow.
e. Either I or II follows


Q9. Old woman's son is my daughter's uncle, then what relation has the old woman to me ?

a. Sister
b. Mother
c. Grandmother
d. Mother - in - law

Q10. Ramu was facing East.He walked 4 km forward and then after turning to his right walked 6 km. Again he turned to his right and walked 7 km. After this he turned back.Which direction was he facing at the time?

a. East
b. North
c. South
d. West
e. North-East


Q11. Raman is not wearing purple and Aman is not wearing black.Raman and Sahil wear different colours.Avinash alone wears green.What is Sahil's colour, if all four of them are wearing different colours.

a. Green
b. Black
c. Purple
d. Can't Say

Q12. The question is followed by two arguments numbered I and II. You have to decide which of the arguments is a strong argument and which is a weak argument.

Statement :
Should a total ban be put on trapping wild animals?
Arguments :
I. Yes, Trappers are making a lot of money.
II. No, bans on hunting and trapping are not effective.

a. Only argument I is strong.
b. Only argument II is strong.
c. Either I or II is strong.
d. Neither I nor II is strong.
e. Both I and II are strong

Q13. The question contains a statement followed by two Assumptions I and II. Find out which assumption(s) is implicit.

Statements:
Vitamin E tablets improve circulation, keep your complexion in glowing condition.
Assumptions :
I. People like glowing complexion.
II. Complexion becomes dull in the absence of circulation.

a. Only assumption I is implicit
b. Only assumption II is implicit
c. Both assumption I and II are implicit.
d. Neither assumption I nor II is implicit

Q14. Study the statement(s) and the conclusions and select the correct option.

Statement :
No country is absolutely self - dependent these days.
Conclusions :
I. It is imposible to grow and produce all that a country needs.
II. Countrymen in general have become lazy.

a. Only Conclusion I follows
b. Only Conclusion II follows
c. Both the conclusion I and II follow
d. Either conclusion I or II follows
e. Neither conclusion I nor II follows

Q15. In the question a statement is followed by some courses of action . A course of action is a step or administrative decisions to be taken for improvement, follow-up, or further action in regard to the problem, policy, etc.You have to assume everything in the statement to be true and then decide which of the given suggested course(s) of action logically follows for pursuing.

Statement:
'The World Bank has approved a $ 300 million loan to finance a project to construct coal ports by Madras Port Trusts.
Courses of Action :
I. India should take financial help from other international financial institutions to develop such ports in other places.
II. India should not seek any help from the international financial institutions.

a. Only I follows
b. Only II follows
c. Either I or II follows
d. Neither I nor II follows
e. Both I and II follow.

amcat question papers 3

amcat placement paper.
amcat interview questions.
amcat question papers.

QUANTITATIVE ABILITY: Sample Questions

All questions are Multiple-Choice-Questions with only one option as the correct answer.

Q1. In a kilometre race, if A gives B a 40 m start, A wins by 19 s. But if A gives B a 30 s start, B wins by 40 m. Find the time taken by B to run 5,000 m?

a. 150 s
b. 450 s
c. 750 s
d. 825 s

Q2. Pipe A takes 16 min to fill a tank. Pipes B and C, whose cross-sectional circumferences are in the ratio 2:3, fill another tank twice as big as the first. If A has a cross-sectional circumference that is one-third of C, how long will it take for B and C to fill the second tank? (Assume the rate at which water flows through a unit cross-sectional area is same for all the three pipes.)

a. 66/13
b. 40/13
c. 16/13
d. 32/13

Q3. Three consecutive whole numbers are such that the square of the middle number is greater than the product of the other two by 1. Find the middle number.

a. 6
b. 18
c. 12
d. All of these

Q4. The arithmetic mean of 2 numbers is 34 and their geometric mean is 16. One of the numbers will be

a. 4
b. 16
c. 18
d. 12

Q5. If x% of a is the same as y% of b, then z% of b is :

a. (xy/z)% of a
b. (yz/x)% of a
c. (xz/y)% of a
d. None of these

Q6. The letters of the word WOMAN are written in all possible orders and these words are written out as in a dictionary ,then the rank of the word 'WOMAN' is

a. 117
b. 120
c. 118
d. 119

Q7. What least number must be subtracted from 9400 to get a number exactly divisible by 65?

a. 40
b. 20
c. 80
d. none of these

Q8. If 2505 / 0.5 = 5010 then 25.05 / 0.5 = ?

a. 5.010
b. 50.10
c. 501.0
d. None of these

Q9. Which pair of rational numbers lie between 1/5 and 2/5 -

a. 262/1000, 275/1000
b. 362/1000, 562/1000
c. 451/1000, 552/1000
d. 121/1000,131/1000

Q10. What is the value of the following expression: 2 log10 5 + log10 4 ?

a. 2
b. 2.5
c. 3
d. None of these

Q11. If x increases linearly, how will a-x behave (a>1) ?

a. Increase linearly
b. Decrease linearly
c. Increase exponentially
d. Decrease exponentially

Q12. What is the probability of getting the sum 5 in two throws of the dice?

a. 1/12
b. 1/5
c. 1/9
d. None of these 

offcampus placement 2013-2014

offcampus placement 2013-2014

The placement season has started. To be a true winner you need to develop skills. 
You need not to be perfect. You just have to become better than others.
Try to learn one language and become master at it. 
you can learn python, java or c#.
Then decide the field you want to go into.
Nowadays cloud computing, android, windows mobile development is a hot area for offcampus placement. 
You can easily get placement int these sectors. Learn the basics of OOPS , DBMS, and software life cycle.
Apply for jobs at timesjobs, monster or google it.
You can also find internship on twenty19. Remember one thing, while going for interview be confident. Sometimes 
even if you don't know the answer then say to them that you don't know the answer and you will read about it whenever you 
go back. This shows that you are ready to learn.
Trust yourself. you going to crack the interview. Its is so simple ;)


Try to remain in contact with professionals like your seniors, relatives and friends. Forward your CV
 to them. Many times when companies have vacancies, they recruit people referred by present employees. So, if you are in touch with them, you will come to know about the vacancy and will get chance to apply. And surely you will get the off campus placement.

all the very best.
remain confident.

cheers !!


Tuesday 15 October 2013

cloud computing

Coming from the beginning of web1.0 when they started using the cloud symbol to represent the internet , the cloud began to grow with the emergence of web 2.0 services and use of the Internet with greater regularity . The advancement of computer technology and communication has made the internet became faster and wider . This provided that Cloud Computing stop being just concept and become a reality .
With Cloud Computing many applications and files do not need to be installed on the user machine . These are maintained by service providers in the cloud and the user only pays for the use of the same . Thus the user need not worry about operational tasks like storage , maintenance , upgrade , backup , scheduling , etc. . On the other side.
When it comes to architecture and depending on the view , cloud computing is a lot like a monolithic architecture , which now have independent computers , but using computing resources in the cloud . From another point of view there is a resemblance to grid computing or computer grid as resources and services can is distributed across multiple servers .
In addition to that environment have the IT Governance . Assisting in organizing the distribution of services and their use can optimize the operation of available resources and reduce costs through better use this .
Currently the service cloud computing is managed primarily in three ways . The first , known as pay as you go ( pay for use) , you pay for the time spent with the resources as we use them .

The second is characterized by the use of demand resources , being called elastic ( elasticity ) , due to the possibility of reducing or increasing resources . And the third , known as Managed (Managed ) , where all the infrastructure is the provider of cloud services and only for it is managed .
Besides these features , we have the possibility of using the cloud with different typology . The three types most widely used and are known as IaaS ( Infrastructure as a Service) , PaaS ( Platform as a Service) and SaaS ( Software as a Service) .
IaaS - Infrastructure as a Service ( Infrastructure as a Service )
This typology infrastructure is offered as a service , providing a complete environment and managed. Depending on the purchase, this management is the responsibility of the customer or the provider.
The level of complexity and network distribution is huge in this typology , being built by large corporations in order to reduce the high costs of maintaining a house infrastructure , maintenance and waste of hardware .
The AWS system was the first widely available IaaS cloud . Its main services include EC2 (Elastic Compute Cloud) , used to manage and run virtual instances of infrastructure and Simple Storage Service ( S3 ) , having a NoSQL database designed to be worn on the EC2 . These services are accessed through an API using SOAP or REST and is becoming increasingly used . Amazon was the corporation responsible for implementing this technology , thus becoming the first corporation to implement IaaS clouds . The main factor that led to the creation of this technology was the need to reduce infrastructure costs idle during periods of low sales .
Following the trend of Amazon , Google also provides services IaaS with huge data centers around the world , including some offshore , taking advantage of both solar energy and natural cooling waters .

The Joyent is also a large company that uses cloud architecture and provides service to social networks like Facebook and LinkedIn .
PaaS - Platform as a Service ( Platform as a Service )
The idea for the PaaS type is transformed into an entire service platform for developing and maintaining software . Thus services are available for production , hosting , testing and management of cloud applications , as well as storage services . Companies that implement this type ensures the advantage of allocating hardware incrementally without having to deal with the physical environment . Some features are integration of web servers , relational database or NoSQL , webservices and combine services by calling mashup , adding services to create new services .
Through the PaaS model the developer does not have to worry about any infrastructure . Just write your code and sends it to the provider that allocates the available software and the Internet . While providing all maintenance needs for software in the cloud, in most cases the programmers have no access to the operating system on which your application is available , with access only through FDI 's web routines upload .
Below are listed the most commonly used platforms in the clouds :
Google App Engine
Enables the use of technology Python or Java to create their applications to Web.
Microsoft Windows Azure
It is a Windows -based environment for creating applications and cloud services . You can use Microsoft Visual Studio for developing and deploying applications on the Azure platform .
Force.com
It is an initiative of Salesforce.com . Provides a development platform for quickly building scalable applications . An Eclipse-based IDE can be used to create , to release and deploy components and applications on the Force.com platform.
Morph
Provides a complete environment called the Morph Application Platform ( MAP ) to host multiple Web applications through their cloud computing infrastructure .
bungee Connect
A complete platform for developing and implementing application for creating web applications to the cloud .
SaaS - Software as a Service ( Software as a Service )
Currently being the most popular type of cloud computing , is always available by large Internet companies like Google , Microsoft and Yahoo .
SaaS has some essential aspects to be characterized as a guarantee that the user data will be made available on the network without loss of security. In addition , the user has no need to know where your software is allocated and not have to worry about upgrades and installations on server or with version control and resolution of system errors.

Service under this typology can be used either for free , such as Google Apps or Microsoft Admin Center as well as paid services generally to enhance and expand services available for free .

Monday 14 October 2013

oops notes - c++ - set 4

1. OVERVIEW OF C++:

What is C++?
C++ is an object-oriented programming language.  Initially named ‘C with classes’, C++ was developed by Bjarne Stroustrup at AT & T Bell Laboratories in Murray Hill, New Jersey, USA, in the early eighties.  Since the class was a major addition to the original C language, Stroustrup called the new language ‘C with classes’, later in 1983 the name was changed to C++.   The idea of C++ comes from the C increment operator ++, thereby suggesting that C++ is an augmented (incremented) version of C.
C++ is a superset of C.  Therefore, almost all C programs are also C++ programs, there are a few minor differences that will prevent a C program to run under C++ compiler.  The three most important facilities that C++ adds on to C are Classes, function overloading, and operator overloading.  These features enable us to create abstract data types, inherit properties from existing data types and support polymorphism, thus making C++ a truly object-oriented language.

Class & Objects
Introducing C++ Classes:
A class may contain private as well as public parts.  By default, all items defined in a class are private.  To make parts of a class public you must declare them after the public keyword.  All variables or functions defined after public can be accessed by all other functions in the program.  In C++ class creates a new data type that may be used to create objects of that type.  An object is an instance of a class in the same way that some other variable is an instance of the int data type.  A class is a logical abstraction while an object is real.
The general form of a simple class declaration is
Class class-name
{
Private:
Variable declarations;
Function declarations;
Public:
Variable declaration;
Function declarations;
};
The class declaration is similar to a struct declaration.  The keyword class specifies that what follows is an abstract data of type class-name. The functions and variables are collectively called members.  They are grouped under two sections, namely, private and public to denote which of the members are private and which of them are public.  The keywords private and public are known as visibility labels.  The members that have been declared as private can be accessed only from within the class.  The public members can be accessed from outside the class also.  The data hiding is the key feature of object-oriented programming.  The use of the keyword private is optional, the members of a class are private.  If both the labels are missing, then by default, all the members are private.
The variables declared inside the class are known as data members and the functions are known as member functions.  Only the member functions can have access to the private data members and private functions.  The public members can be accessed from outside the class.
Object: is a basic runtime entity which may be a person, an item or something like time, date etc.
Ex.
Class item
{
int number;    //variable declaration
float cost;        //private by default
public:
void getdata(int a, float b);   //function declaration
void putdata(void);                //using prototype
}
The class item contains two data members and two function members.  The data members are private by default while both the functions are public by declaration.  The function getdata( ) can be used to assign values to the member variables number and cost, and putdata( ) for displaying their values.

Fuction Overloading:
Overloading refers to the use of the same thing for different purposes.  C++ also permits overloading of function.  This means that we can use the same function name to create functions that perform a variety of different tasks.  This is known as function polymorphism in OOP.  We can design group of functions with one function name but with different argument lists.  The function would perform different operations depending on the argument list in the function call.  The correct function to be invoked is determined by checking the number and type of the arguments but not on the function type.

Ex.
#include<iostream>
using namespace std;
// abs is overloaded three ways
int abs(int i);
double abs(double d);
long abs(long l);
int main( )
{
cout<<abs(-10)<<”\n”;
cout<<abs(-11.0)<<”\n”;
cout<<abs(-9L)<<”\n”;
return 0;
}
int abs(int i)
{
cout<<”using integer abs( )\n”;
return  i<0 ? –i : i;
}
double abs(double d)
{
cout<<”using double abs( )\n”;
return d<0.0 ? –d : d;
}
long abs(long l)
{
cout<< “using long abs( )\n”;
return l<0 ? -1 : 1;
}
output:                                    //10      11        9

Operator Overloading:
The operator overloading is an important technique that has enhanced the power of C++.  C++ tries to make the user-defined data types in much the same way as the built-in type.  C++ permits us to add two variables of user-defined types with the same syntax that is applied to the basic types. This means that C++ has the ability to provide the operators with a special meaning for a data type, this mechanism is known as operator overloading. To define an additional task to an operator, we must specify the class to which the operator is applied. This is done with the help of a special function, called operator function.
The general form of an operator function is
Returntype classname::operator op(arg-list)
{
Function body
}
Where returntype is the type of value returned by the specified operation and op is the operator being overloaded.  The op is preceded by the keyword operator.  Operator op is the function name.
Inheritance:
Inheritance allows a hierarchy of classes to be built, moving from most general to most specific.  The process involves first defining a base class, which defines those qualities common to all objects to be derived from the base.  The base is usually referred to as derived classes.  A derived class includes all features of the generic base class and then adds qualities specific to the derived class.
Ex.
//The building class is declared, it will serve as the base for two derived classes.
Class building
{
in rooms;
int floors;
int area;
public:
void set_rooms(int num);
int get_rooms( );
void set_floors(int num);
int get_floors( );
void set_area(int num);
int get_area( );
};
Because all buildings have three common features, one or more rooms, one or more floors, and a total are the building classes these components into its declaration.  The member functions beginning with set the values of the private data. The function starting with get return those values.
Constructors and Destructors:





Constructors
A constructor function is a special function that is a member of a class and has the same name as that class.  The constructor is invoked whenever an object of its associated class is created.  It is called constructor because it construct the values of data members of the class.
A constructor is declared and defined as follows:
Class integer
{
int m,n;
public:
integer(void); //constructor declared
………….
………….
};
integer::integer(void)            //constructor defined
{
m=0;n=0;
}
When a class contains a constructor like the one defined above, it is guaranteed that an object created by the class will be initialized automatically. A constructor that accepts no parameter is called the default constructor.

Ex.
#include <iostream.h>
class integer
{
int m,n;
public:
integer(int, int);          //constructor declared
void display(void)
{
cout<<”m=”<<m<<”\n”;
cout<<”n=”<<n<<”\n”;
}
};
integer::integer(int x, int y)   //constructor defined
{
m=x; n=y;
}
main( )
{
integer int1(0,100);
integer int2=integer(25,75);
cout<<”\n object1”<<”\n”;
int1.display( );
cout<<”\nobject2”<<”\n”;
int2.display( );
}
output:            //object1          m=0     n=100  object2            m=25   n=75


Destructor:
A destructor, as the name implies, is used to destroy the objects that have been created by a constructor.  Like a constructor, the destructor is a member function whose name is the same as the class name but is preceded by a tilde. Ex. The destructor for the class integer can be defined as shown below:
~integer( ) { }
A destructor never takes any argument nor does it return any value.  It will be invoked  implicitly by the compiler upon exit from the program to clean up storage that is no longer accessible.  Whenever new is used to allocate memory in the constructors, we should use delete to free that memory.

Ex.
#include<iostream.h>
int count=0;
class alpha
{
public:
alpha( )
{
count++;
count<<”\n no. of object created”<<cout;
}
~alpha( )
{
cout<<”\n no. of object destroyed”<<cout;
count--;
}
};
main( )
{
cout<<”\n\n Enter main\n”;
alpha a1,a2,a3,a4;
{
cout<<”\n\n Enter Block1\”;
alpha a5;
}
{
cout<<\n\n Enter Block2\n”;
alpha a6;
}
cout<<”\n\n Re-enter main\n”;
}

C++ Keywords:
The keywords implement specific C++ language features.  There are 63 keywords currently defined for standard C++.  They are explicitly reserved identifiers and cannot be used as names for the program variables or other user-defined program elements.
Asm                 auto                 bool                 break               ase                   catch
char                 class                 const                const_cast       continue          default
delete              do                    double             dynamic_cast  else                  enum
explicit                        export              extern              false                 float                 for
friend              goto                 if                      inline               int                    long

Friend Functions:
A friend function has access to all private and protected members of the class for which it is a friend.  To declare a friend function, include its prototype within the class, preceding it with the keyword friend.  The private members cannot be accessed from outside the class.  That is a non-member function cannot have an access to the private data of a class.  There could be a situation where we would like two classes to share a particular function.  Ex. Consider a case where two classes, manager and scientist, have been defined.  We would like to use a function income_tax( ) to operate on the objects of both these classes.  In such situations, C++ allows the common function to be made friend with both the classes, allowing the function to have access to the private data of these classes.  Such a function need not be a member of any of these classes.  The friend function of the class declared as.
Class ABC
{
……….
………
public:
………
……….
Friend void xyz(void);            //declaration
};

Ex
#include<iostream>
using namespace std;
class myclass
{
int a,b;
public:
friend int sum(myclass x);
void set_ab(int i, int j);
};
void myclass::set_ab(int i, int j)
{
a=i;
b=j;
}
// sum( ) is not a member function of any class.
int  sum(myclass x)
{
return x.a+x.b;
}
int main( )
{
myclass n;
n.set_ab(3,4);
cout<<sum(n);
return 0;
}
The sum( ) function is not a member of myclass.  It still has full access to its private members.  The sum( ) is called without the use of the dot operator.  Because it is not a member function, it does not need to be qualified with an object’s name.
Ex.
#include <iostream.h>
using namespace std;
class sample
{
int a;
int b;
public:
void setvalue( )
{ a=25; b=40;}
friend float mean(samle s);
};
float mean(sample s)
{
return float(s.a+s.b)/2.0;
}
main( )
{
sample x;
x.setvalue( );
cout<<”mean value=”<<mean(x)<<”\n”;
}

Friend Classes:

It is possible for one class to be a friend of another class.  When this is the case, the friend class and all of its member functions have access to the private members defined within the other class.
#include<iostream>
using namespace std;
class twovalues
{
int a;
int b;
public:
twovalues(int i, int j) {a=i;b=j;}
friend class min;
};
class min
{
public:
int min(twovalues x);
};
int min::min(twovalues x)
{
return x.a<x.b?x.a:x.b;
}
int main( )
{
twovalues ob(10,20);
min m;
cout<<m.min(ob);
return 0;
}

In this example, class min has access to the private variables a and b declared within the two values class.  It is critical to understand that when one class is a friend of another, it only has access to names defined within the other class.  It does not inherit the other class.  The members of the first class do not become members of the friend class.










5. Inline Functions:

There is an important feature in C++ called an inline function, you can create short functions that are not actually called their code is expanded inline at the point of each invocation.  This process is similar to using a function-like macro. One of the objectives of using functions in a program is to save some memory space, which becomes appreciable when a function is likely to be called many times.  Every time a function is called, it takes a lot of extra time tin executing a series of instructions for tasks such as jumping to the function, saving registers, pushing arguments into the stack and returning to the calling function.  To eliminate the cost of calls to small functions,
#include<iostream.h>
#include<stdio.h>
inline  int max(int a, int b)
{
return a>b?a:b;
}
int main( )
{
cout<<max(10,20);
cout<<” “<<max(99,88);
return 0;
}

Inline functions may be class member functions.

#include<iostream>
using namespace std;
class myclass
{
int a,b;
public:
void init(int i, int j);
void show( );
};
// create inline function
inline void myclass::init(int i, int j)
{
a=i;
b=j;
}
//create another inline function
inline void myclass::show( )
{
cout<<a<< “”<<b<<”\n”;
}
int main( )
{
myclass x;
x.init(10,20);
x.show( );
return 0;
}

Defining Inline Functions within a Class:
It is possible to define short functions completely within a class declaration.  When a function is defined inside a class declaration, it is automatically made into an inline function.  It is not necessary to precede its declaration with the inline keyword.
#include<iostream>
using namespace std;
class myclass
{
int a,b;
public:
// automatic inline
void init(int i, int j)
{
a=i; b=j;
}
void show( )
{
cout<<a<<””<<b<<”\n”;
}
};
int main( )
{
myclass x;
x.init(10,20);
x.show( );
return 0;
}


Static Members:

When you precede a member variable’s declaration with static, you are telling the compiler that only one copy of that variable will exist and that all objects of the class will share that variable.  Unlike regular data members, individual copies of a static member variable are not made for each object.  How many objects of a class are created, only one copy of a static data member exists.  All objects of that class use that same variable.  All static variables are initialized to zero before the first object is created.
#include <iostream>
using namespace std;
class shared
{
static int a;
int b;
public:
void set(int i, int j)
{
a=i;
b=j;
}
void show( );
};
int shared::a;//define a
void shared::show( )
{
cout<<”This is static a:”<<a;
cout<<”\n this is non-static b”<<b;
cout<<”\n”;
}
int main( )
{
shared x,y;
x.set(1,1);        // set a to 1
x.show( );
y.set(2,2);        // change a to 2
y.show( );
x.show( );
return 0;
}


Static Member Functions
Member functions may also be declared as static.  There are several restrictions placed on static member functions.  They may only directly refer to other static members of the class.  A static member function does not have this pointer.  There cannot be a static and a non-static version of the same function.  A static member function may not be virtual, finally they cannot be declared as const or volatile.
Ex.
#include<iostream>
using namespace std;
class static_type
{
static int i;
public:
static void init(int x)
{
i=x;
}
void show( )
{
cout<<i;
}
};
int main( )
{
static_type::init(100);
static_type x;
x.show( );        //display 100
return 0;
}

Arrays of Objects:
It is possible to have arrays of objects.  The syntax for declaring and using an object array is exactly the same as it is for any other type of array.
# include<iostream.h>
class c1
{
int i;
public:
void set_i(int j) {i=j;}
int get_i( ) {return i;}
};
int main( )
{
c1 ob[3];
int i;
for(i=0; i<3; i++)
ob[i].set_i(i+1);
for(i=0; i<3; i++)
cout<<ob[i].get_i( ) <<”\n”;
return 0;
}                                                           // output 1,2,3
Creating Initialized vs. Uninitialized Arrays:
A special case situation occurs if you intend to create both initialized and uninitialized  arrays of objects.  Consider the following class.
Class c1
{
int i ;
public:
c1(int j) {i=j;}
int get_i( ) { return i ;}
};
Ex.

Class c1{
Int i;
Public:
C1( ) {i=0; }    // called for non-initialized arrays
C1(int j) {i=j;}            // called for initialized arrays
Int get_i( ) {return I;}

Given this class both of the following statements are permitted.
C1 a1[3]={3,5,6};       // initialized
C1 a2[34];       // uninitialized

8. Pointers to Objects:

You can have pointers to other types of variables, you can have pointers to objects.  When accessing members of a class given a pointer to an object, use the arrow (->) operator instead of the dot operator.
Ex.
#include<iostream.h>
class c1
{
int i;
public:
c1(int j) {i=j;}
int get_i( ) {return i;}
};
int main( )
{
c1 ob(88) , *p;
p=&obj;           //get address of ob
cout<<p->get_i( );       // use -> to call get_i( )
return 0;
}

When a pointer is incremented, it points to the next element of its type.  An integer pointer will point to the next integer.  All pointer arithmetic is relative to the base type of the pointer.  The same is true of pointers to objects.
Type checking C++ pointers:
You may assign one pointer to another only if the two pointer types are compatible.  For example
Int *pi;
Float *pf;
In C++ , the following assignment is illegal
Pi=pf;  //error type mismatch






The this Pointer:
When a member function is called, it is automatically passed an implicit argument that is a pointer to the invoking object , This pointer is called this.  To understand this, first consider a program that creates a class called pwr that computes the result of a number raised to some power.
#include<iostream.h>
class pwr
{
double b;
int e;
double val;
public:
pwr(double base, int exp);
double get_pwr( ) { return val;}
};
pwr::pwr(double base, int exp)
{
b=base;
e=exp;
val=1;
if(exp==0) return;
for(;exp>0; exp--) val=val*b;
}
int main( )
{
pwr x(4.0,2), y(2.5, 1), z(5,7,0);
cout<<x.get_pwr( )<<” ”;
cout<<y.get_pwr( )<< “ “;
cout<<z.get_pwr( )<<”\n”;
return 0;
}
b=base;
means that the copy of b associated with the invoking object will be assigned the value contained the base.  The same statement can also be written like this.
this->b=base;
The this pointer points to the object that invoked pwr( ) , Thus this->b refers to that objects copy of b.  here is the entire pwr( ) function written using the this pointer.
pwr::pwr(double base, int exp)
{
this->b=base;
this->e=exp;
this->val=1;
if(exp==0) return;
for(;exp>0; exp--)
this->val=this->val*this->b;
}

Pointers to Derived Types:
A pointer of one type cannot point to an object of a different type, there is an important exception to this rule that relates only to derived classes.  Assume two classes called B and D, assume that D is derived from the base class B.  In this situation a pointer of type B* may also point to an object of type D, a base class pointer can also be used as a pointer to an object of any class derived from that base.  A base class pointer can be used to point to a derived object, the opposite is not true.  A pointer of type D* may not point to an object of type B.
#include<iostream.h>
class base
{
int i;
public:
void set_i(int num) {i=num;};
int get_i( ) {return i;}
};
class derived:public base
{
int j;
public:
void set_j(int num) {j=num;}
int get_j( ) {return j;}
};


int main( )
{
base *bp;
derived d;
bp=&d;            //base pointer points to derived object
//          access derived object  using base pointer
bp->set_i(10);
cout<<bp->get_i( )<<” “;
return 0;
}

Pointers to Class Members:
To generate a special type of pointer that points to a member of a class, not to a specific instance of that member in an object.  This sort of pointer is called a pointer to a class member or a pointer-to-member, a pointer to a member is not the same as a normal C++ pointer.  A pointer to a member provides only an offset into an object of the member’s class at which that member can be found.  Member pointers are not true pointers, the . and -> cannot be applied to them, the special pointer-to-member operators .* and ->* .



#include<iostream.h>
class c1
{
public:
c1(int i) {val=i;}
int val;
int double_val( )         { return val+val;}
};
int main( )
{
int c1::*data;              //data member pointer
int (c1::*func)( );       // function member pointer
c1 ob1(1),ob2(2);        //create objects
data=&c1::val;           //get offset of val
func=&c1::double_val;         // get offset of double_val
cout<<”here are values”;
cout<<ob1.*data<<” “<<ob2.*data<<”\n”;
cout<<”here they are doubled”;
cout<<(ob1.*func) ( )<<” “;
cout<<(ob2.*func) ( )<<”\n”;
return 0;
}

This program creates two member pointers: data and func.  When declaring pointers to members, you must specify the class and use the scope resolution operator.  The program also creates objects of c1 called ob1 and ob2, the member pointers may point to either functions or data, the program obtains the addresses of val and double_val( ).

Reference to Derived Types:
A base class reference can be used to refer to an object of a derived class.  The most common application of this is found in function parameters.  A base class reference parameter can receive objects of the base class as well as any other type derived from that base.
Restrictions to References:
There are a number of restrictions that apply to references.  You cannot reference another reference.  You cannot obtain the address of a reference.  You cannot create arrays of references.  You cannot create a pointer to a reference.  You cannot reference a bit-field.  A reference variable must be initialized when it is declared unless it is a member of a class, a function parameter, or a return value.  Null references are prohibited.

Dynamic Memory Allocation Operators:

C++ provides two dynamic allocation operators, new and delete.  These operators are used to allocate and free memory at run time.  Dynamic allocation is an important part of all programs.  C++ supports dynamic memory allocation functions, called    malloc ( ) and free().  The use of new and delete operators they have several advantages.
The new operator allocates memory and returns a pointer to the start of it.  The delete operator frees memory previously allocated using new.  The general form of new and delete are.
p_var=new type;
delete p_var;

Here p_var, is a pointer variable that receives a pointer to memory that is large enough to hold an item of type.  Since the heap is finite, it can become exhausted.  If there is insufficient available memory to fill an allocation request.  Then new will fail and a bad_alloc exception will be generated.
#include<iostream.h>
int main()
{
int *p;
try
{
p=new int;      // allocate space for an int
}
catch(bad_alloc xa)
{
cout<<”allocation failure\n”;
}
*p=100;
cout<< “At”<<p<<” “;
cout<< “is the value”<<*p<<”\n”;
delete p;
return 0;
}
This program assigns to p an address in the heap that is large enough to hold an integer.  It then assigns that memory the value 100 and displays the contents of the memory on the screen.
Initializing Allocated Memory:
You can initialize allocated memory to some known value by putting an initialize after the type name in the new statement.  The general form of new is.
p_var=new var_type(initializer);
the type of the initializer must be compatible with the type of data for which memory is being allocated.  The following program gives the allocated integer an initial value of 87
#include <iostream.h>
#include<new.h>
int main()
{
int *p;
try
{
p=new int(87);           //initialize of 87
}
catch (bad_alloc xa)
{
cout<<”allocation failure\n”;
return 1;
}
cout<<”at”<<p<<””;
delete p;
return 0;
}



Allocating Arrays:
You can allocate arrays using new by using this general form.
p_var=new array_type[size];
Here size specifies the number of elements in the array.
To free an array, use this form of delete.
Delete[]p_var’
Here, the[] informs delete that an array is being released.
For example, the next program allocates a 10 element integer array.
#include<iostream.h>
#include<new.h>
int main()
{
int *p, i;
try
{
p=new int[10];           // allocate 10 integer array
}
catch (bad_alloc xa)
{
cout<<”allocation failure\n”;
return 1;
}
for(i=0; i<10; i++)
p[i]=I;
for(i=0; i<10; i++)
cout<<;[i]<<””;
delete[]p; // release the array
return 0;
}

Allocate Objects:
You can allocate objects dynamically by using new.  When you , an object is created and a pointer is returned to it.  The dynamically created object acts just like any other object.  When it is created, its constructor function is called.  When the object is freed, its destructor function is executed.
Here is a short program that creates a class called balance that links a person’s name with his or her account balance.  Inside main() an object of type balance is created dynamically.

#include<iostream.h>
#include<new.h>
#include<cstring.h>
class balance
{
double cur_bal;
char name[80];
public:
void set(double n, char *s)
{
cur_bal=n;
strcpy(name, s);
}
void get_bal(double &n, char *s)
{
n=cur_bal;
strcpy(s, name);
}
};
int main()
{
balance *p;
char s[80];
double n;
try
{
p=new balance;
}
catch (bad_alloc xa)
{
cout<<”allocation failure\n”;
return 1;
}
p->set(12387.87, “Ralph wilson”);
p->get_bal(n,s);
cout<<s<<”is balance is”<<n;
cout<<”\n”;
delete p;
return 0;
}



The nothrow Alternative:
In C++ it is possible to have new return null instead of throwing an exception when an allocation failure occurs.  This form of new is most useful when you are compiling older code with a modern C++ compiler.  It is also valuable when you are replacing calls to malloc( ) with new.
P_var=new(nothrow)type;
Here p_var is a pointer variable of type.  The nothrow form of new works like the original version of new from years ago.  Since it returns null on failure, it can be dropped, older code without having to add exception handling.
#include<iostream.h>
#include<new.h>
int main( )
{
int *p, i;
p=new(nothrorw) int[32];     // use notrhrow option
if(!p)
{
cout<<”Allocation failure\n”;
return 1;
}
for(i=0; i<32; i++) p[i]=i;
for(i=0; i<32; i++) cout<<p[i]<<” “ ;
delete [ ] p;     // free the memory
return 0;
}

The Placement Forms of new and delete:
There is a special form of new, called the placement form, that can be used to specify an alternative method of allocating memory.  It is primarily useful when overloading the new operator for special circumstances.  The general form.
P_var=new(location)type;
Here location specifies an address that is simply returned by new.  There is also a placement form of delete, which is used to free memory allocated by the placement form of new.