Skip to main content


Showing posts from September, 2012

Limit the number of objects being created in JAVA

Q   :- Limit the number of objects being created in JAVA.
Sol :- The example below limits creation of objects of MyClass class to a maximum of 5 by declaring the constructor private and calling it via getMyClass() method.If an attempt to create more than 5 objects is done, the getMyClass() method will return a null,thus,the object so created will not be referenced and ultimately cleared by the garbage collector. import*; class MyClass { public static int count=0; int a; private MyClass() { count++; a=count; System.out.println("object created  = "+a); if(count>4) System.out.println("Object Creation Limit Exceeded"); } public static MyClass getMyClass() { if(MyClass.count==5) return null; else return new MyClass();

Limiting the number of objects created in JAVA

Q   :- How can you limit the number of objects created in java ?

Sol :- In the example below MyClass constructor has been used to limit the  number of objects that can be created to 2 by using a count which has been declared static(single copy for all objects of a class).If one tries to create more than 2 objects the constructor will throw an error. 

class LimitInstanceOfObject
public static void main(String [] args) throws Exception
MyClass obj1,obj2,obj3,obj4;
obj1=new MyClass();
obj2=new MyClass();;;
catch(Exception e)
obj3=new MyClass();
obj4=new MyClass();;;
catch(Exception e)

class MyClass
public static int count=0;
public MyClass() throws Exception
throw new Exception("Object creation limit exceeded !");
System.out.println("count = "+count);
public void fun()


Important Interview Questions with Answers

1) Tell me something about yourself?

I am a person with strong interpersonal skills and have the ability to get along well with people. I enjoy challenges and looking for creative solutions to problems.
Besides the details given in my resume, I believe in character values, vision and action. I am quick in learning from mistakes. I am confident that the various tests that you have conducted will corroborate my competencies aptitude and right attitude for the job.

2) What do you seek from a job?

I would like a job which gives me a chance to apply all that I have learned in college as well as one which enables me to grow as a professional. I would like a role which enables me to make a difference.
Great learning opportunities, challenging roles, rational career progression, good job satisfaction and opportunities to use my strength organization that gives me the opportunity to serve the organization and the society.

3) How would you present your strengths ?

Always re…

For Intelligence Bureau (IB) ACIO Some Important Note..

IB ACIO stands for Intelligence Bureau Assistant Central Intelligence Officers. The ACIO Exam is conducted to recruit ACIO in the Intelligence Bureau which proudly claims to be one of the oldest intelligence agencies in the world.

There is uncertaintly over what exactly ACIO does in the Intelligence Bureau. His exact duties are not defined properly due to the seriousness of this job. As you may know that Intelligence Bureau is responsible for internal intelligence in the country. The job of IB is to collect information about terror organizations and maoists and forward it to relevant department.

To become a Assistant Central Intelligence Officer, each candidate is required to appear in a entrance exam. On passing this exam, you would get to work in prestigious organization like Intelligence Bureau. Here are the eligibility Criteria to appear in ACIO Exam.

Eligibility Criteria
~~ You should be Indian
~~ The maximum age limit for ACIO is 27 years.
~~ You need to have a graduation degree in a…

Must Read... Worth Sharing....

A group of highly educated students visited their old university professor. Conversation soon turned into complaints about stress in work and life.
Offering them coffee, Professor returned from kitchen with a pot of coffee and an assortment of cups- porcelain, glass, crystal, some plain looking, some expensive, some exquisite - telling them to help themselves to hot coffee. When all had a cup of coffee in hand,
The professor said: "If U noticed, all the nice looking expensive cups were taken up, leaving behind the plain ones. While it's but normal for U to want only the best, that's also the source of Ur stress. What U really wanted was coffee, not the cup, But U still went for the best cups nd were eyeing each other's cups!" :)

"If life is coffee, Then jobs, money and status in society are the cups. They are just tools to hold and contain Life.
Don't let the cups drive U.."
Enjoy the coffee

Challenge – Equal Probability between 1 and 7

              Write a method to generate a random number between 1 and 7, given a method that generates a random number between 1 and 5. The distribution between each of the numbers must be uniform.

              Let’s think of this like a decision tree. Each rand5() will be a decision. After 2 tries, we have 25 possible solutions. We try to get maximum bunches of 7 as we can (1 – 21, 3 sets of 7). If we get any of the other values, we just try again. Since the probability of getting each of 21 values are the same every time, trying again won’t affect their probabilities.

int rand7() { while (1) { int num = 5*(rand5()-1) + rand5(); if (num < 22) return ((num % 7) + 1); } } That was fun, right? Anyone up for another challenge? Watch out for it next tuesday (March 1st).

Challenge – Find First Common Ancestor

               How would you find the first common ancestor of two nodes in a binary search tree? First as in the lowest in the tree. Another way to ask is to find the lowest common ancestor of two nodes.

 Meanwhile, check out the challenges from previous weeks here

TreeNode findFirstCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if (root == null) { return null; } if (root == p || root == q) { return root; } TreeNode left = findFirstCommonAncestor(root.left, p, q); TreeNode right = findFirstCommonAncestor(root.right, p, q); if ((left == p && right == q) || (left == q && right == q)) { return root; } return (left != null) ? left : right; }

TreeNode findFirstCommonAncestor(TreeNode root, int p, int q) { if (root == null) { return null; } if (root.value == p || root.value == q) { return root; } if (root.value > p && root.value > q…

Challenge – 50 trucks with payload

               Given a fleet of 50 trucks, each with a full fuel tank and a range of 100 miles, how far can you deliver a payload? You can transfer the payload from truck to truck, and you can transfer fuel from truck to truck. Assume all the payload will fit in one truck.

 Meanwhile, check out the challenges from previous weeks here

Answer :
              We want to use as little fuel as possible so we try minimize the number of trucks we use as we go along. Let’s say we start with all 50 trucks with full fuel (5000 miles range). For each mile, we lose 50 miles in range. After two miles, we lose 100 miles leaving us with 4900 miles. This can be supported by 49 trucks so we drop one truck.
As you can see for every 100 miles we lose in range, we drop a truck.
50 trucks: 100/50
49 trucks: 100/49

Total distance = 100/50 + 100/49 + 100/48 + … + 100/2 + 100/1 (harmonic series) = 449.920533833

how to maintain session in asp 3.5 with c#

There are different ways. You can use form authentication , it's a way to do that.

<system.web> <authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="All" timeout="30" name=".ASPXAUTH" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" /> </authentication> <authorization> <allow users="admin" /> <deny users="*" /> </authorization> </system.web> private void btnLogin_Click(object sender, System.EventArgs e) { if (Validate(txtUsername.Text, txtPassword.Text)) { FormsAuthentication.Initialize(); String strRole = txtUsername.Text; FormsAuthenticationTicket fat = new Forms…

What are the career opportunities available for MCA, Engineering Graduates?

Now that we live in the age of information technology, there is a world of opportunities waiting for MCA graduates like you. Although understandably, you might be apprehensive about your future considering that workforce competition can be quite stiff, you need not worry as long as you plan your career ahead of time.
You need not be scared of not being able to find a job. I’m here to help you. I suggest that you take a moment to learn some helpful tips and insights outlined in this section so that you will not have any problems in finding your dream job.
Career Options for MCA Graduates As an MCA graduate, you possess excellent computer skills and the ability to develop or create computer applications, understand and utilize various computer languages, as well as provide maintenance and repair to different types of applications, among others. With these technical skills, you would surely find employment in the following positions:
Software engineerSoftware dev…

Some Question and answers

1. Using the digits 1,5,2,8 four digit numbers are formed and the sum of all possible such numbers.

2. Four persons can cross a bridge in 3,7,13,17 minutes. Only two can cross at a time. find the minimum time taken by the four to cross the bridge.

3. Find the product of the prime numbers between 1-20

4. 2,3,6,7--- using these numbers form the possible four digit numbers that are divisible by 4.

5. Two trains are traveling at 18kmph and are 60 km apart. There is fly in the train. it flies at 80kmph. It flies and hits the second train and then it starts to oscillate between the two trains. At one instance when the two trains collide it dies. Distance traveled by the fly when both trains collide is Ans.---12km

6. there are 1000 doors that are of the open-close type. When a person opens the door he closes it and then opens the other. When the first person goes he opens-closes the doors ion the multiples of 1 i.e., he opens and closes all the doors. when the sec…

e-Admit Card for Combined Defence Services Examination (II) 2012

For Downloading of e-Admit Card for Combined Defence Services Examination (II) 2012, pleaseClick Here PRESS NOTE The Union Public Service Commission will be conducting the Combined Defence Services Examination (II), 2012 on 16th September, 2012 (Sunday) at 41 Centers all over India as per notification dated 2nd June, 2012.  The Commission has introduced the facility of generating e-Admit Card for this Examination for convenience of candidates. Rejection Letters citing the ground (s) for rejection have been dispatched and also put on the Union Public Service Commission Website  .  In case of any difficulty faced by the candidates for downloading e-Admit Card, they may contact the UPSC Facilitation Counter on Telephone Nos. 011-23385271, 011-23381125 and 011-23098543 on any working day between 10.00 AM and 5.00 PM.  The candidates can also send Fax message on Fax No. 011-23387310.  No paper Admission Certificate will be sent by post.                 I…

Implementing Queue Using Stack

Question: How would you use stacks to implement a queue?
Answer: So how could we go about doing this? What if we used two stacks and used one as the incoming stack and the other as the outgoing stack? A queue is a FIFO structure, so when we enqueue something, we need to make sure that it does not get popped off before something that was already there. Similarly, when we dequeue something, we have to make sure that elements that were inserted earlier get ejected first.

What’s better than some code!
Stack in; Stack out; void enqueue( int value ) { while( !out.isEmpty() ) { in.push( out.pop() ); } in.push( value ); } int dequeue() { while( !in.isEmpty() ) { out.push( in.pop() ); } return out.pop(); }
Isn’t that cool? Help share this on Facebook and Twitter!

Answer- to Camel and Bananas Challenge

Thanks for all the responses. Quite a few of you have the right answer.

The Question was: The owner of a banana plantation has a camel. He wants to transport his 3000 bananas to the market, which is located after the desert. The distance between his banana plantation and the market is about 1000 kilometer. So he decided to take his camel to carry the bananas. The camel can carry at the maximum of 1000 bananas at a time, and it eats one banana for every kilometer it travels.
What is the largest number of bananas that can be delivered to the market?

And the here is the Answer: At KM#0, we have 3000 bananas. The maximum bananas the camel can carry is 1000 so the camel must at least make 3 trips from the start point. (Leave #0, Return to #0, Leave #0, Return to #0, Leave #0).
If we move just 1km, we need 1 banana for each step mentioned above thus making a total of 5 bananas for each km.
We continue making 3 trips until we reach a banana count of 2000.
3000 – 5*d = 2000 => d…

Challenge – Camel and Bananas Comment your Answer

Question: The owner of a banana plantation has a camel. He wants to transport his 3000 bananas to the market, which is located after the desert. The distance between his banana plantation and the market is about 1000 kilometer. So he decided to take his camel to carry the bananas. The camel can carry at the maximum of 1000 bananas at a time, and it eats one banana for every kilometer it travels.
What is the largest number of bananas that can be delivered to the market?

Challenge: Do you know the answer to this question? Post in the comments.
The Answer will be posted on 10th Sept

You Can see the Answer for this Challenge Here After Scheduled Date

Puzzle and Interview Questions 2 - 08 sep 2012

Question:  Count the number of Cubes

Press Button to See the Answer See Answer

CTS- Cognizant Technology Solution Selection Procedure

CTS Selection Procedure consists of following 3 rounds 1. PPT. 2. Aptitude Test.
3. HR and Technical. PPT-30 -40 minutes 1. Written Test No of questions : 55
Time limit : 60 minutes
No negative mark
Sectional cut off

In written test consists two section

Section -1- Analytical Ability (30 Ques in 30 mints) For analytical : For analytical (Areas to concentrate)
1. Puzzles (4Ques)
2. Figure-Odd-1 (1ques)
3. Syllogism ( including 2 statements which are mostly asked)....(2 Ques)
4. Coding decoding(4Ques)
5. Logical connectives
6. Data sufficiency
7. Data interpretation (2)
8  Pie chart and table
8. Statement-Conclusion.
9. Blood relation.
10. Cube and dice.
11. Statement inference (true or false like)......(2 Ques)
12. Figure Sequence(4Ques)
13. Puzzles Practice Tests for Quantitative Aptitude Tips and Tricks to learn Quantitative Aptitude For verbal:
1. Error in sentences.(10Ques)
2. Rearrange.
3. Passage.(2 Big Passage)(10Questions)
4. Jumble Sentence

Verbal section seems to be little toug…

Cognizant Company Profile and it's information for Interview

HQ Teaneck, NJ
Industry Information Technology Services
Size 130K+ Employees, $6B+ Revenue
Competitors Infosys, Wipro, Tata Consultancy Services

About cognizant
Cognizant Corporate view:
Cognizant is an American multinational IT services and consulting corporation headquartered in Teaneck, New Jersey, United States.
Cognizant has been named to the 2010 Fortune 100 Fastest-Growing Companies List for the eighth consecutive year. Cognizant has also been named to the Fortune 1000 and Forbes Global 2000 lists. It has consistently ranked among the fastest growing companies including the 2010 Business Week 50 list of the top-performing U.S. companies, the Business Week Hottest Tech Companies 2010, and the Forbes Fast Tech 2010 list of 25 Fastest Growing Technology Companies In America.
Founded: 1994
Headquarters: Teaneck, New Jersey, U.S.

Key people: 
Francisco D'Souza (President & CEO)
Lakshmi Narayanan (Vice Chairman)

Placement Review for Credit Suisse 2012 – pattern | Interviews | Tests

Hey let me declare, that this post is not by me it's a review from a friend who attended the Credit Suisse Campus :) 
Description: CREDIT SUISSE
It consisted of 8 puzzles and 8 algoritms/pseudocodes.
For puzzles refer to ‘how to ace the brain teaser’. For algorithms refer ‘cracking the coding interview’ and be familiar with questions asked in carrer cup site.There was one DB qstn too. We were asked to design a schema and normalize it.
Interview 1: Complete tech.
There were 2 bonus questions in the apti to design a client server architecture. I hadn’t solved it in apti so i was asked to explain it.
I was asked about my BE project, how i will implement it and explain the algorithms i will be using etc.
Thwn he asked me a simple puzzle.that chicken,corn and fox wala.
I was asked my fav subject, to which i said database. Then i was asked indexing, structures used, RAID levels. I was asked to design a database schema and write simple queries on it.
Then i was asked to exp…

Difficult interview questions about management Skills

12 difficult interview questions about management I. Contents of difficult interview questions
Questions below will help you interview candidates about their management skill at difficult level.
II. Difficult interview questions of management skill 1. What do you look for when you hire people?
2. Tell me about a time when you had to deal with a co-worker who wasn’t doing his/her fair share of the work. What did you do and what was the outcome?
3. Are you a good manager? Can you give me some examples? Do you feel that you have top managerial potential?
4. Give me an example of a time when you took the time to share a co-worker’s or supervisor’s achievements with others?
5. Tell me about a time that you misjudged a person?
6. How do you get along with older (younger) co-workers?
7. What is your management style?
8. How do you deal with authority?
9. What qualities do you feel a successful manager should have?
10. What is your biggest strength as a manager?
11. How to do …

Difficult interview questions

9 difficult interview questions about new job.
I. Contents of difficult interview questions
Questions below will help you interview candidates about their new job at difficult level.
II. Difficult interview questions of new job 1. How long would it take you to make a meaningful contribution to our firm?
2. How long would you stay with us?
3. Please give me your definition of the position for which you are being interviewed?
4. What important trends do you see in our industry?
5. Why do you want to work for us?
6. What do you know about our organization?
7. Why do you want to work here?
8. How would you evaluate your present firm?
9. Do you have any questions?

Stress interview questions

It include 27 stress questions as follows:
1. Direct stress questions
• Do you consider standing in a line as stressed work?
• Define stress and when do you get stressed out?
• Are you able to work under stress?
• Please give us an example about you work with a team that faced stress from your experience?
• Why do you think it will conduce stress?
• What is the worst thing when you faced with stress?
• Which transaction is not good for your colleagues whom also faced the stress at the same time?
• How do you handle stress? What is the best thin or work you do when you are stressed out?
2. Stress questions by conflict • Okay, if that’s the best answer you can give me. Then what about this question…?
• I don’t really feel like your answering the question. Could you please clarify / could you please start again?”
3. Stress questions Pressure • How do you handle rejection?
• What is the worst thing that you have heard about our company?
4. Other stress questions • Why are manhole cove…