面试时最经常被问到的问题(Frenquently asked interview questions)(II)

来源:互联网 发布:研究生教材最优化 编辑:程序博客网 时间:2024/05/17 06:14
面试时最经常被问到的问题(Frenquently asked interview questions)之Analytical, puzzles, and brain-teasers篇

Analytical, puzzles, and brain-teasers Questions & Answers

1If you had an infinite supply of water and a 5 quart and 3 quart pail, how would you measure exactly 4 quarts?

2If you could remove any of the 50 states, which state would it be and why?

--I would not remove any of them, (provided the definition of state is the USA's states). Could you imagine the gerrymandering after something like that? Besides - each state has something special it brings to its star on the flag. That is what makes the USA so remarkable.

--I will ask the interviewer for the definition of "remove" first.
If ( the answer is dig a hole, let water bubble up)
{
    I would say I "remove" a state lack of water supply.
}
else if ( the answer is give it up or give it away to other countries )
{
    I would say it's some state with the biggest area of desert. And I would definitely trade sth. back from whom want it
} else // default,
{
    I will keep it for possible future usage
}

3If you are on a boat and you throw out a suitcase, will the level of water increase?

-- The answer is: it depends on the density of the briefcase. While the briefcase is in the boat, it will displace it's weight in water.

If the briefcase floats after you toss it out, then it still displaces its weight in water, and there is no change.

However, if the briefcase is heavier than water it will displace its volume, not its weight. The amount of displaced water will be less (which is why it sank) and the water level will decrease.

-- The other question is whether or not the suitcase is thrown in the water. If it is thrown on to a dock or land, then the level will decrease due to less weight in the boat.

4There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner. What is the probability that they don't collide?

--- 1. Let's mark the corners of the triangle as A,B,C.
2. There are only two cases under which the ants won't collide : A->B, B->C, C->A and A->C, C->B and B->A
3. Therefore, probability of ants not colliding : 2/8 = 1/4.

---This assumes that ants move in a straight line, as we know they don't. They move all over the place, in random directions, eventually ending up in their final destinations. Although Microsoft asked me this question and was looking for the answer mentioned by other posters, they gave extra credit for what I explained.

--- You are all wrong! You have made not one but three obvious assumptions!
1) They move in straight lines.
2) They start within the confines of the triangle.
3) They stay within the confines of the triangle.

Moral: Think out of the triangle!!

5Three men were renting a motel figuring the room cost 30 dollars they would pitch in ten a piece. The room was only 25 so they each gave the bell boy ten,(tip)the bellboy didn"t think that would be fair so he gave them each back 1 dollar and kept 2 for himself. What happened to the other dollar? ( sent by MACsabastion@webtv.net )

Oh after giving it some thought actually I was right, there isn't any missing dollar.

If you go backwards you come up to this:
9x3 = 27
27+2 = 29
so it had to be 30$ in order to be correct right?
No, because you have to add 3$ and not 2. You think it would be right if you add 2$ because the tip is that amount. But the tip is already included in the multiplication.
So the maths aren't right, it should be 9x3+3 and not 9x3+2.

6"You have b boxes and n dollars. If I want any amount of money from 0 to n dollars, you must be able to hand me 0 to b boxes so that I get exactly what I request." The two questions were " What are the restrictions on b and n, and how is money distributed among the boxes?"

The trick is of Binary Numbers


2^0=1
2^1=2
2^2=4
2^3=8
2^4=16
....
...

2^7=128
...


The formula is [log n to base 2] + 1 = b
where [] denote integral part of the log base 2 of n

Example
So if we want 0 to 15 dollars
[log of 15 to base 2] + 1 = [3.90] + 1 = 3 + 1 = 4 boxes
we need to have 4 boxes each having 1,2,4,8, dollars respectively.Now we know from binary numbers that any amount from 0 to 15 can be formed with this boxes.

For 0 to 6 dollars
[log of 7 to base 2] + 1 = [2.58] + 1 = 2 + 1 = 3 boxes
we need to have 3 boxes each having 1,2,4, dollars respectively

For 0 to 100 dollars
[log of 100 to base 2] + 1 = [6.64] + 1 = 6 + 1 = 7 boxes
we need to have 7 boxes each having 1,2,4,8,16,32,64 dollars respectively

-Ameya Vaidya

7What is the sum of the numbers from 1 to 1000?

Depends what NUMBER means here:

If means integer, that's 100*(100+1)/2=5050;
If not, that's infinity.

8You are an employer. You have ten employees. Each month, each one of your ten employees gives you ten bags of gold. Each bag of gold has ten pieces of gold in it. Each piece of gold weighs one pound. One of your employees is cheating you by only putting nine pieces of gold in each of his ten bags of gold. You have a scale (not a balance, a scale), and you can only take one measurement from the scale, only one (1) reading. How can you tell which of the ten employees is cheating you by using this scale and only taking one measurement?

---When your employees come to pay you at the end of the month, take one bag from employee number one's pile and set it aside. Take two bags from employee number two's pile and add it to the one from employee number one. Take three from employee three, four from employee four, etc...

Once you have now compiled a pile of bags, you should have 55 bags (one from one, two from two, etc). Set the whole pile (all 55 bags) on the scale and take a reading. If all the bags were honest, you would have 550 pounds on the scale.

If employee one is cheating you, then the reading would be 549, since you only have one bag from employee one. Likewise, if the measurement is 547, then 3 pounds are missing, and employee three is the thief.

--- I think we are given a scale not a balance. So we can’t tell the exact weight of the bags. So how do we find out whether its 549, 547 etc.?

--- Why does he need to weigh? Can't he just count?

9How many points are there on the globe where by walking one mile south, one mile east and one mile north you reach the place where you started.

--At the North Pole, The South Pole wouldn't quite work, since you can only go north from the South Pole.

--Both answers (North Pole, and all points on the circle 1 mile north of the circle having circumference of 1 mile around the South Pole) are right.

10How would go about finding out where to look for a book in a library? (You do not know how the books are organized beforehand)

-- I would go and ask a person in charge of arranging the books instead of wasting my time in searching all of them

-- This question is open ended , though Microsoft might be testing fundamentals on Binary search , Indexing etc by asking this.

The approach I would take is , check out the index cards and find the shelf where the book is located. Then do an alphabetical search by physically going to that shelf. You can also say that you would start on the top of the shelf or the bottom depending on the "letter" name of the book etc.

-- I would leave the library, drive to the exact location of the person who wrote this question, and slap them.

11Imagine you are standing in front of a mirror, facing it. Raise your left hand. Raise your right hand. Look at your reflection. When you raise your left hand your reflection raises what appears to be his right hand. But when you tilt your head up, your reflection does too, and does not appear to tilt his/her head down. Why is it that the mirror appears to reverse left and right, but not up and down?

-- It's mainly because man himself is "left-right" symetric but not "up-down" symetric.

-- This is not a Physics issue... this is a matter of perception.

When you stand in front of the mirror and raise YOUR LEFT HAND, the reflection is of YOUR LEFT HAND.

By referring to "what appears to be his right hand" the question has essentially asked you to envision yourself rotated 180 degrees about a vertical axis, thus subtly introducing the apparent conflict between left and right.

Why it works: Since humans are relatively symmetric along a vertical axis you are able to envision YOUR LEFT HAND as a suitable RIGHT HAND for your reflection.

Humans are not generally symmetric along a horizontal axis (hey, I've never seen it, but that doesn't mean some freak isn't out there...), so it's much harder to envision feet as a suitable head and vice versa.

12You have a bucket of jelly beans. Some are red, some are blue, and some green. With your eyes closed, pick out 2 of a like color. How many do you have to grab to be sure you have 2 of the same?

If you select 4 Jelly beans you are guaranteed that you will have 2 that are the same color.

13You are given a scale which you are to use to measure eight balls. Seven of these balls have the same weight: the eight ball is heavier than the rest. What is the minimum number of weighs you could perform to find the heaviest of the eight balls?. Remember it's a scale not a balance. (i.e. It can just tell you if one side is heavier than the other it can't give you the exact weight).

!..Umm. You can do this in 2 weighs. Put three balls on each side of the scale. That's a total of six balls you're weighing. If the three balls on each side weigh equally, you know that one of the two remaining balls is the heaviest. Weigh those two balls to determine which one is heaviest. If, however, one of the three ball combinations weighs most, remove all balls from the scale, then weigh just two of the three "heavier" balls. If those two balls are equal weight, the third, unweighed ball is the heaviest; otherwise the scale will indicate which of the two balls on the scale is the heavier one.

So, what’s the difference between a balance and a scale?

14How would you design a toaster?

1. Find out Voltage to be supported
2. '' '' 2-pin/3 pin plug ?
3. '' '' How many slots for bread?
4. '' '' what size bread ?
5. Automatic pop-up
6. Easily accessible for cleaning and maintenance
7. Easily operable
8. Compact and good looking
9. Design a simple circuit that uses components that are easily available.
10. Internet enabled ?
11(?). Provide a place to keep the stack of bread slices, a settable counter, place to keep the plate, toaster automatically picks up bread from the stack, "toasts" it and places it on the plate.

12. Also could provide a butter holder that melts the butter and sprinkles it on the toast, once done.
13. Optional alarm that rings after the job is done (entire stack is toasted)
14. Optical sensor to sense the actual browning of the bread (different settings for wheat and white bread)

.. And so on.... :))

15How would you design an universal remote control?

16How would you design a clock for a blind person?

I would design a clock with Brail Code, Self talk and vibration and with capabilities for disabling any of those features depending on the requirement. Since vibration is very difficult to design, they can be set aside in another version of the clock.

17How many miles of road are there in the US?

-- This series of questions is called Guesstimates, and tests ur ability to make meaningful guesses and assumptions. Some other questions like this are 'how many helicopters are flying overhead right this moment?' and 'what is the number of tennis balls made in the US annually?'

-- actually this questions is like that : how many cars in USA u can answer any number u want and argue later: ask the interviewer to count them for u, if he finds more cars than , more cars have been bought since he last counted ..., if less then a lot of cars have been scrapped...
the same thing applies to road also, enjoy

-- I guess this is funny!! I would rather say, 0.625 times the number of kms in USA:)

18There are n couples attending a party. Each one shakes hands with the persons he doesn't know. (Assuming each person knows his/her partner) Mary and John are a couple. John asked the rest of the party-attenders how many times he has shaken hands. Each one gives a unique answer. How many times does Mary shake hands?

 
面试时最经常被问到的问题(Frenquently asked interview questions)之Algorithms & Coding篇

Algorithms & Coding Questions & Answers

1、Write a function to print the Fibonacci numbers.


-- int fib ( int n ){
if (n == 0) return 1;
else return fib(n-1) + fib(n-2);
}

-- int fibo (int n)
{
int i, current, one_back, two_back;

if (n <= 1)
return 1;
else {
one_back = 1;
two_back = 1;
for ( i = 2; i <= n; i++) {
current = one_back + two_back;
one_back = two_back;
two_back = current;
} /* end for loop */
} /* end else block */
return current;
}


-- There are better ways to find a solution to this problem instead of using Recursion. Recursion is a disaster as someone has already mentioned. Try giving 20 or more elements in your series and your program will take awful lot of time to compute. For every element in series you're finding the element before using recursion though you theoretically you would have computed it before!!!

2.Give a one-line C expression to test whether a number is a power of 2. Now implement it without using loops.

-- if (x > 0 && (x & (x-1)) == 0)

-- I think all the answers here are either wrong completely, partially, or too complex. The best answer so far, by jinaljhaveri, was if(!(x&(x-1))), which I believe works for all powers of 2, but also for 0, which is not a power of 2.

Basically, an integer which is the power of 2 will have one and only one bit set in its binary representation. If you subtract 1 from that, you will get all bits set (equal to 1) before the original 1 bit, and the rest are 0. Taking advantage of this, the answer is

if ((x << 1) == 1 + (x | (x - 1))) {}

The term x | (x - 1) makes an integer with all bits set starting from the original set bit. Adding 1 will set the next bit and clear all the previous bits, effectively doubling x, which is the same as x << 1.

It’s a pity that the second solutions work for 0 too, which is just what he/she wants to avoid.

3.Implement an algorithm to sort a linked list.

直接插入排序、直接选择排序、归并排序

如果可以使用的额外的内存空间,会比较的简单;否则,则需要一点思考了。

4.Reverse a string.


void str_rev(char s[])
{
int len = strlen(s);
int i;
char temp;

for(i=0; i<len/2; i++)


{
temp = s[i];
s[i] = s[(len-1) - i];
s[(len-1) - i] = temp;
}
}


 

5.Given a linked list which is sorted, how will you insert in sorted way.

U have already very familiar with it if you did question 3 (sort a linked list) by direct insertion sort.

6.Implement an algorithm to insert in a sorted list.

7.Delete an element from a doubly linked list.

void deleteNode(node *n)
{
node *np = n->prev;
node *nn = n->next;
np->next = n->next;
nn->prev = n->prev;
delete n;
}

8.Implement an algorithm to sort an array.

An array can be sorted using any of the classic algorithms like quicksort , heapsort and the inefficient bubblesort.

9.Given a sequence of characters, how will you convert the lower case characters to upper case characters?

void ToUpper(char * S)
{
while (*S!=0)
{
*S=(*S>='a' && *S<='z')?(*S-'a'+'A'):*S;
S++;
}
}

10.Write a routine that prints out a 2-D array in spiral order.


int NumbersPerTime = SIZE;  // 绕圈的边长

         int tInit = 0;                                     // 绕圈的起始值

 

         for(int i = 0 ; i < (SIZE+1)/2; i++)

         {

                   int t = tInit;

 

                   for(int j = 0; j < NumbersPerTime-1; j++)

                   {

                            // out here

                            printData(t);

                            t += SIZE;

                   }

                   for(j = 0; j < NumbersPerTime-1; j++)

                   {

                            // out here

                            printData(t);

                            t += 1;

                   }

                   for(j = 0; j < NumbersPerTime-1; j++)

                   {

                            // out here

                            printData(t);

                            t -= SIZE;

                   }

                   for(j = 0; j < NumbersPerTime-1; j++)

                   {

                            // out here

                            printData(t);

                            t -= 1;

                   }

 

                   NumbersPerTime -= 2;

                   tInit += SIZE + 1;

     }


11.Give a fast way to multiply a number by 7.

int num = (n<<3) – n;

12.Write a function that takes in a string parameter and checks to see whether or not it is an integer, and if it is then return the integer value.


int str2int(const char *str)
{
int value = 0;
int sign = (str[0] == '-')?-1:1;
int i = (str[0] == '-')?1:0;
char ch;

while(ch = str[i++])

{
if ((ch >= '0')&&(ch <= '9'))
value = value*10 + (ch - '0');
else
return 0;     // return 0 denotes error occurs
}
return value*sign;
}


13.How would you print out the data in a binary tree, level by level, starting at the top?

1) Put the root node into a queue;
2) while the queue is not empty, do as follows;
3) Get a node from the queue, print its value, and put its children into the queue;

14.Write a routine to draw a circle given a center coordinate (x, y) and a radius (r) without making use of any floating point computations.

In order to avoid floating point calculations, we can do two things:

1) Instead of fixing one co-ordinate and looking for another via the equation, search the whole co-ordinate space from x +- r and y +- r. Plot the point that is close. But this is a costly N*N algo.

2) To go for an efficient workhorse, go for Bresenham's circle drawing algo, found in any of the good graphics textbooks.

15.You are given two strings: S1 and S2. Delete from S2 all those characters which occur in S1 also and create a clean S2 with the relevant characters deleted.


#include<stdio.h>
#include<string.h>
main() {
char str1[5] = "abcd";
char str2[3] = "bc";
int len = strlen(str1);
int i =0;
char newstr[len];
int cntr = 0;
for ( i = 0; i<len; i++ ) {
if ( strchr(str2,str1[i]) == NULL ) {
newstr[cntr++] = str1[i];
}
}
newstr[cntr] = '/0';
printf("%s%s%s", "The new str is ", newstr, "/n");
}


16.Write a small lexical analyzer for expressions like "a*b" etc.

bool is_astarb(char* s)
{
if (*s++ != 'a') return false;
while(*s++);
if (*--s != 'b') return false;
return true;
}

17.Given an array t[100] which contains numbers between 1 and 99. Return the duplicated value. Try both O(n) and O(n-square).

-- Traverse array to compute sum, subtract 99*100/2, the sum of integers between 1 and 99.

-- Create a new array of b[100], elements initialized all to 0


int b[100];
for ( i=0;i<100;i++)
b[i]=0;
int tm;
for ( i=0;i<100;i++)
{
tm=t[i] ;
if b[tm]== 1;
return(tm);  // return the duplicate number
else b[tm]=1;
}
printf(" there is no duplication");
return 0;     // 0 indicates no duplication


O(n square ) ... just sort all numbers and check if two consecutive numbers are same by traversing the sorted array..

18.Write efficient code for extracting unique elements from a sorted list of array.


#include <stdio.h>

main()
{
int a[10] = {0,4,4,4,5,6,6,8,9,9};
int i;

for(i=0; i<10; i++)
{
if(a[i] == a[i+1] )
{
while(a[i] == a[i+1]) i++;
}
else
printf("%d ", a[i]);
}
printf("/n");
}


We do print the ununiqued numbers out, but we do not extract them!

19.Print an integer using only putchar. Try doing it without using extra storage.


1) void printInt(int a);
int b = a;
char *str;
int i = 1;
int len = 0;
while (b) {
b /= 10;
i *= 10;
len++;
}
i /= 10;

while (i > 0) {
putchar(a/i + 48);
a = a%i;
i /= 10;
}
}

2) This can be done by recursion. Since the number of recursive calls is not significant, it does not affect the performance much.

printnumber(int i)
{
if(i == 0)
return;
printnumber(i/10);
putchar('0' + i%10);
}


20.Write a function that allocates memory for a two-dimensional array of given size(parameter x & y)

--array=(int**)malloc(x*sizeof(int*));
for(i=0;i<y;i++)
array[i]=(int*)malloc(y*sizeof(int));

--I prefer this method because it uses less memory allocation calls and the memory is in a contiguous line. I used calloc.. which can easily be swaped out with malloc. Also, this makes a 2d array of integers but that is easily changed as well.

int x = 0, y = 0;
Array = (int **) calloc( Height, sizeof(int *));
*(Array) = (int *) calloc( Width * Height, sizeof(int));

for(y = 0; y < Height; y++)
{
Array[y] = &(Array[0][x]);
x += Width;
}

21How would you do conditional compilation ?

#ifdef/ifndef
#else/elif
#endif

#pragma token-string       // provide compiler or machine specific instructions and arguments

22Write an algorithm to draw a 3D pie chart ?

23Write a function that finds repeating characters in a string.

Maintain a character count table like -- int char_count[255];

//Initialize to 0 here
Keep adding the count of each characters.
Scan throughout the array and print the characters with count more than 1.

24Write a routine to reverse a series of numbers without using an array.


-- int reverse(int i)
{
int rev=0, x=0;
if((i /10) ==0)
return i;
while((i /10) >0)
{
x = i %10;
i= i/10;
rev= (rev *10) +x;
}
rev= rev*10 +i;

return rev;
}

-- # include <iostream.h>
void main()
{
int i = 12345, y =0;
while(i !=0)
{
y = y *10 + i %10;
i /=10;
}
cout<<y;
}


25Write a function to find the nth item from the end of a linked list in a single pass.

I would think keeping a gap is "n" between fptr and sptr would do. Then advance both together till fptr->next (fptr is the one in front) = NULL, the sptr is what we want.

26Write a function to compute the factorial of a given integer.

27Give me an algorithm for telling me the number I didn't give you in a given range of numbers. (Numbers are given at random)

1. say the range of numbers is 0 to n-1
2. Initialize an array say, seen[n] to 0
3. for every number i given set seen[i] to 1.
4. in the end, print all indices for which seen[index] = 0

28Write a function that finds the last instance of a character in a string.

main() {

       char *x= "acbcd";

       char y = 'c';

       int len = strlen(x);

       int i=0,j=0;

       for( i = len-1; i>= 0; i-- ) {

              if ( x[i] == y ) {

                     break;

              }

       }

       printf("%s%c%s%d%s","the # of last occur of ",y," is ",i+1,"/n");

}

 

面试时最经常被问到的问题(Frenquently asked interview questions)之终结篇--提问面试官

Questions for the Interviewer

Try to ask your interviewer some relevant and interesting questions. Do not waste time by asking questions with publicly available answers. 

Ask questions that will help you make a decision on whether you would like to work for that company.

l         What would a normal working day be like?

l         Is it possible to move between departments?

l         How much contact is there with management?

l         Is this position more analytical or people-oriented?

l         How soon could I expect to be advanced to the next level in the career path?

l         How much travel is normally expected?

l         Will I be expected to meet certain deadlines? How frequent are they?

l         How often are performance reviews given?

l         How much decision-making authority is given after one year?

l         Does the company provide any educational benefits?

l         Have any new product lines/services/curricula been announced recently?


面试时最经常被问到的问题(Frenquently asked interview questions)之Microsoft and other companies篇

Microsoft Interview Questions

Interviewing at Microsoft used to be different from Interviwing at other companines. However, with the advent of a new economy and the Internet things have changed dramatically in the past few years. 

More and more companies are adopting Microsoft Interviewing philosophy and hence their questions. Here is a typical set of Interview questions asked for an entry level Software Design Engineer(SDE) or Internship position.

·  If you had an infinite supply of water and a 5 quart and 3 quart pail, how would you measure exactly 4 quarts?

·  If you are on a boat and you throw out a suitcase, will the level of water increase?

·  On an average, how many times would you have to open the Seattle phone book to find a specific name?

·  There are 3 ants at 3 corners of a triangle, they randomly start moving towards another corner. What is the probability that they don't collide?

·  If you look at a clock and the time is 3:15, what is the angle between the hour and the minute hands? ( The answer to this is not zero!)

·  What new feature would you add to MSWORD if you were hired?

·  Why did you pick the school you graduated from?

·  Why do you want to work for Microsoft?

·  How many Gas stations are there in the US?

·  How would you weigh a plane without using scales?

·  How would you move Mt. Everest?

·  Two MIT math graduates bump into each other at Fairway on the upper west side. They hadn't seen each other in over 20 years.
The first grad says to the second: "how have you been?"
Second: "Great! I got married and I have three daughters now"
First: "Really? how old are they?"
Second: "Well, the product of their ages is 72, and the sum of their ages is the same as the number on that building over there.."
First: "Right, ok.. oh wait.. hmmmm.., I still don't know"
second: "Oh sorry, the oldest one just started to play the piano"
First: "Wonderful! my oldest is the same age!"

Problem: How old are the daughters?

·  Why are beer cans tapered at the top and bottom?

·  Why is it that hot water in a hotel comes out instantly but at home it takes time?

·  How many times a day a clock's hands overlap?

·  Mike has $20 more than Todd. How much does each have given that combined they have $21 between them. You can't use fractions in the answer.(Hint: This is a trick question, pay close attention to the condition)

·  There are four dogs, each at the counter of a large square. Each of the dogs begins chasing the dog clockwise from it. All of the dogs run at the same speed. All continously adjust their direction so that they are always heading straight towards their clockwise neighbor. How long does it take for the dogs to catch each other? Where does this happen? (Hint: Dog's are moving in a symmetrical fashion, not along the edges of the square).

 

Misc. frequently asked questions by other companies:

l         Have you used any tools to do Java application development? Have you used any application server?

l         How would you design and develop Internet based, scalable, mission-critical middle-tier and backend software solutions.

l         Do you have any commercial software design and development experience with Object-Oriented, multi-threaded application development using Windows or J2EE(Java or C/C++ environments).

l         What tools can you use to check your Java or C++ code for errors?

l         Do you know C++, C, ASP, Java, SQL, JSP, GSP, XML, Oracle, Sybase etc?

l         What real-time, event driven operating systems you are familiar with?

l         Have you built middle-tier and backend components using c-sharp ( Java ) and XML.

l         Have have you been involved in designing, developing and testing software products?

l         Have you used any off-the-shelf testing tool to do automatic software testing

l         How would you go about optimizing an application for performance or isolate problems?

l         What tools can you use to test Java/C++ based applications

 
Oracle面试问题-技术篇
这也许是你一直期待的文章,在关注这部分技术问题的同时,请务必阅读有关面试中有关个人的问题和解答。这里的回答并不是十分全面,这些问题可以通过多个角度来进行解释,也许你不必在面试过程中给出完全详尽的答案,只需要通过你的解答使面试考官了解你对ORACLE概念的熟悉程度。

  1.解释冷备份和热备份的不同点以及各自的优点
  解答:热备份针对归档模式的数据库,在数据库仍旧处于工作状态时进行备份。而冷
备份指在数据库关闭后,进行备份,适用于所有模式的数据库。热备份的优点在于当备份
时,数据库仍旧可以被使用并且可以将数据库恢复到任意一个时间点。冷备份的优点在于
它的备份和恢复操作相当简单,并且由于冷备份的数据库可以工作在非归档模式下,数据库
性能会比归档模式稍好。(因为不必将archive log写入硬盘)
  2.你必须利用备份恢复数据库,但是你没有控制文件,该如何解决问题呢?
  解答:重建控制文件,用带backup control file 子句的recover 命令恢复数据库。

  3.如何转换init.ora到spfile?
  解答:使用create spfile from pfile 命令.
  4.解释data block , extent 和 segment的区别(这里建议用英文术语)
  解答:data block是数据库中最小的逻辑存储单元。当数据库的对象需要更多的物理
存储空间时,连续的data block就组成了extent . 一个数据库对象拥有的所有extents被
称为该对象的segment.
  5.给出两个检查表结构的方法
  解答:1.DESCRIBE命令
     2.DBMS_METADATA.GET_DDL 包
  6.怎样查看数据库引擎的报错
  解答:alert log.

7.比较truncate和delete 命令
  解答:两者都可以用来删除表中所有的记录。区别在于:truncate是DDL操作,它移动
HWK,不需要rollback segment .而Delete是DML操作, 需要rollback segment 且花费较长
时间.
  8.使用索引的理由
  解答:快速访问表中的data block
  9.给出在STAR SCHEMA中的两种表及它们分别含有的数据
  解答:Fact tables 和dimension tables. fact table包含大量的主要的信息而dime
nsion tables 存放对fact table 某些属性描述的信息
  10.FACT Table上需要建立何种索引?
  解答:位图索引 (bitmap index)
  11. 给出两种相关约束?
  解答:主键和外键
  12. 如何在不影响子表的前提下,重建一个母表
  解答:子表的外键强制实效,重建母表,激活外键
  13. 解释归档和非归档模式之间的不同和它们各自的优缺点
  解答:归档模式是指你可以备份所有的数据库 transactions并恢复到任意一个时间点
。非归档模式则相反,不能恢复到任意一个时间点。但是非归档模式可以带来数据库性能
上的少许提高.
14. 如何建立一个备份控制文件?
  解答:Alter database backup control file to trace.
  15. 给出数据库正常启动所经历的几种状态 ?
  解答:STARTUP NOMOUNT – 数据库实例启动
     STARTUP MOUNT - 数据库装载
     STARTUP OPEN – 数据库打开
  16. 哪个column可以用来区别V$视图和GV$视图?
  解答:INST_ID 指明集群环境中具体的 某个instance 。
  17. 如何生成explain plan?
  解答:运行utlxplan.sql. 建立plan 表
     针对特定SQL语句,使用 explain plan set statement_id = 'tst1' into pl
an_table
     运行utlxplp.sql 或 utlxpls.sql察看explain plan
  18. 如何增加buffer cache的命中率?
  解答:在数据库较繁忙时,适用buffer cache advisory 工具,查询v$db_cache_adv
ice.如果有必要更改,可以使用 alter system set db_cache_size 命令
  19. ORA-01555的应对方法?
  解答:具体的出错信息是snapshot too old within rollback seg , 通常可以通过增
大rollback seg来解决问题。当然也需要察看一下具体造成错误的SQL文本
  20. 解释$ORACLE_HOME和$ORACLE_BASE的区别?
  解答:ORACLE_BASE是oracle的根目录,ORACLE_HOME是oracle产品的目录。
21. 如何判断数据库的时区?
解答:SELECT DBTIMEZONE FROM DUAL;

22. 解释GLOBAL_NAMES设为TRUE的用途
解答:GLOBAL_NAMES指明联接数据库的方式。如果这个参数设置为TRUE,
在建立数据库链接时就必须用相同的名字连结远程数据库

23。如何加密PL/SQL程序?
解答:WRAP

24. 解释FUNCTION,PROCEDURE和PACKAGE区别
解答:function 和procedure是PL/SQL代码的集合,通常为了完成
一个任务。procedure 不需要返回任何值而function将返回一个值
在另一方面,Package是为了完成一个商业功能的一组function和proceudre
的集合

25. 解释TABLE Function的用途
解答:TABLE Function是通过PL/SQL逻辑返回一组纪录,用于
普通的表/视图。他们也用于pipeline和ETL过程。

26. 举出3种可以收集three advisory statistics
解答:Buffer Cache Advice, Segment Level Statistics, Timed Statistics

27. Audit trace 存放在哪个oracle目录结构中?
解答:unix $ORACLE_HOME/rdbms/audit
Windows the event viewer

28. 解释materialized views的作用
解答:Materialized views 用于减少那些汇总,集合和分组的
信息的集合数量。它们通常适合于数据仓库和DSS系统。

29. 当用户进程出错,哪个后台进程负责清理它
解答: PMON

30. 哪个后台进程刷新materialized views?
解答:The Job Queue Processes.

31. 如何判断哪个session正在连结以及它们等待的资源?
解答:V$SESSION / V$SESSION_WAIT

32. 描述什么是 redo logs
解答:Redo Logs 是用于存放数据库数据改动状况的物理和逻辑结构。
可以用来修复数据库.

33. 如何进行强制LOG SWITCH?
解答:ALTER SYSTEM SWITCH LOGFILE;

34. 举出两个判断DDL改动的方法?
解答:你可以使用 Logminer 或 Streams

35. Coalescing做了什么?
解答:Coalescing针对于字典管理的tablespace进行碎片整理,将
临近的小extents合并成单个的大extent.


36. TEMPORARY tablespace和PERMANENT tablespace 的区别是?
解答:A temporary tablespace 用于临时对象例如排序结构而 permanent tablespaces
用来存储那些'真实'的对象(例如表,回滚段等)


37. 创建数据库时自动建立的tablespace名称?
解答:SYSTEM tablespace.

38. 创建用户时,需要赋予新用户什么权限才能使它联上数据库。
解答:create session

39. 如何在tablespace里增加数据文件?
解答:ALTER TABLESPACE <tablespace_name> ADD DATAFILE <datafile_name> SIZE <size>

40. 如何变动数据文件的大小?
解答:ALTER DATABASE DATAFILE <datafile_name> RESIZE <new_size>;

41. 哪个VIEW用来检查数据文件的大小?
解答: DBA_DATA_FILES

42. 哪个VIEW用来判断tablespace的剩余空间
解答:DBA_FREE_SPACE

43. 如何判断谁往表里增加了一条纪录?
解答:auditing

44. 如何重构索引?
解答: ALTER INDEX <index_name> REBUILD;

45. 解释什么是Partitioning(分区) 以及它的优点。
解答:Partition将大表和索引分割成更小,易于管理的分区。


46. 你刚刚编译了一个PL/SQL Package但是有错误报道,如何显示出错信息?
解答:SHOW ERRORS

47. 如何搜集表的各种状态数据?
解答: ANALYZE
The ANALYZE command.

48. 如何启动SESSION级别的TRACE
解答: DBMS_SESSION.SET_SQL_TRACE
ALTER SESSION SET SQL_TRACE = TRUE;

49. IMPORT和SQL*LOADER 这2个工具的不同点
解答:这两个ORACLE工具都是用来将数据导入数据库的。
区别是:IMPORT工具只能处理由另一个ORACLE工具EXPORT生成
的数据。而SQL*LOADER可以导入不同的ASCII格式的数据源


50。 用于网络连接的2个文件?
解答: TNSNAMES.ORA and SQLNET.ORA
black_snail


ibm的java面试题

1.    简答题:
  a)  在你心中,J2EE是什么样的?请用三句话描述清楚。
  b)  会话EJB主要分为哪两种类型?它们的主要区别是什么?谁的性能更好,为什么?
  c)  EJB的开发人员必须为每个EJB提供哪三个类型的Java对象?这些Java对象必须继承或实现哪些接口(对于Session EJB和Entity EJB有区别时应该分开回答)?
  d)  在EJB中是否允许从方法中返回一个this 引用,或者将this 引用作为参数传递。有
没有其它方法可以获得当前EJBObject的引用?
  e)  EJB容器的任务是什么?
  f)  客户怎样得到一个EJB实例的远程引用?
  g)  EJB可以使用哪些类型的事务划分方法? 它们各自的优势是什么?
  h)  下面哪个语句能够正确地创建一个InputStreamReader的实例?
     i.   new InputStreamReader(new FileInputStream("data"));
     ii.  new InputStreamReader(new FileReader("data"));
     iii. new InputStreamReader(new BufferedReader("data"));
     iv.  new InputStreamReader("data");
     v.   new InputStreamReader(System.in);
  i)  传递给实现了java.awt.event.MouseMotionListener接口的类中mouseDragged()方法的事件对象是什么类型的。
  j)   当用户在TextField中输入一行文字后,按回车,实现什么接口可实现对事件的响应。
  k)   下面正确的创建Socket的语句有
    i.    Socket a = new Socket(80);
    ii.    Socket b = new Socket("130.3.4.5",80);
    iii.    ServerSocket c = new Socket(80)
    iv.    ServerSocket d = new Socket("130.3.4.5",80)
  l)    RMI注册程序的默认端口是什么?
  m)    Naming 类的哪些方法能将远程对象绑定到RMI注册对象上?
  n)    远程接口要扩展什么package的什么接口?
2.    问答题:
  a)  请简要描述一下J2EE架构的层次结构,并介绍每个层次所提供的功能。注:建议用图示+文字的形式答题。
  b)    判断以下各个语句是否正确。如果不正确,请说明原因。
    i.    与一个典型的实体EJB相关联的数据存储在一个关系数据库中。
    ii.   实体EJB的远程接口表示了与它相关联的数据库表格。
    iii.  使用bean管理持久性的实体EJB要求部署者指定对数据库进行插入、更新、删除和查询的SQL语句。
    iv.    实体EJB的本地接口会在底层数据库中插入一个新的记录。
    v.    实体EJB会在ejbCreate中获得必须的资源。
    vi.    使用容器管理持久性的EJB必须实现CMPEntitiyBean接口,而使用bean管理持久性
的EJB必须实现EntitiyBean接口。
  c)  判断下列语句是否正确。如果不正确,请解释原因。
      i.  带有页作用域的对象在一个Web应用程序的每个JSP中都存在。
      ii. 指令指定与一个特定的JSP请求不相关的全局信息。
      iii.    当JSP容器遇到开始定制标签和结束定制标签时,分别调用doInitBody方法和doA
fterBody方法。
     iv.    <jsp:include>动作只在翻译时处理一次。
     v.    与XHML文档相似,JSP注释和脚本语言注释出现在对客户的响应中。
    vi.    带有应用程序作用域的对象是特定Web程序的一部分。
    vii.    每个页都有它自己的页作用域隐含对象的实例。
3.    编程题
   a)  写一个JavaBean,这个JavaBean显示"Hello World"这几个字,在一个Applet中使用这个JavaBean。
   b)  编写一个RMI的server端和client端,server端提供一个加法接口,接口可以接收两个整数,返回的是它们相加的结果。Client端则调用server端的这个功能做加法。
   c)  编写一个程序,用选择法对数组a[]={20,10,50,40,30,70,60,80,90,100}进行从大到小的排序。
   d)  创建两个线程,每个线程打印出线程名字后再睡眠,给其它线程以执行的机会,主线程也要打印出线程名字后再睡眠,每个线程前后共睡眠5次。要求分别采用从Thread中继承和实现Runnable接口两种方式来实现程序.