Interview Questions and Answers for 'Goldman sach' - 20 question(s) found - Order By Rating Q1. Are you willing to spend long hours ? General
Ans. why not if getting money in dollars! Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q2. How do you make instance of an abstract class ? Core Java
Ans. By extending it to the derived class and thereby creating instance of derived class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q3. A Kid can go up 1, 2 or 3 stairs in one step. Write a method that takes number of steps in a stair will print all possible ways he can take.
For example , printAllCombinations(3) should print
111
12
21
3
Similarly , printAllCombinations(4) should print
1111
121
13
211
22
31
4 Core Java
Ans. public static String findStep(int n) {
if (n == 1 || n == 0)
return 1;
else if (n == 2)
return 2;
else
return findStep(n - 3) + findStep(n - 2) + findStep(n - 1);
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  coding Asked in 1 Companies Q4. Why java doesn't support multiple Inheritance ?
or
Explain Java Diamond Problem. Core Java
Ans. class A {
void test() {
System.out.println("test() method");
}
}
class B {
void test() {
System.out.println("test() method");
}
}
Suppose if Java allows multiple inheritance like this,
class C extends A, B {
}
A and B test() methods are inheriting to C class.
So which test() method C class will take? As A & B class test() methods are different , So here we would Facing Ambiguity. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  multiple inheritance  object oriented programming (oops)  oops concepts  diamond problem Asked in 20 Companies basic   frequent Very Frequently asked to Senior Software Engineers or Developers. Q5. Describe some of the Design Patterns you have used ? Design
Ans. [Open Ended Answer] Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  design patterns Asked in 17 Companies intermediate   frequent Q6. Can there be a Thread without a Process ? Core Java
Ans. No. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Thread  Process Asked in 1 Companies Basic Q7. What is Dirty read in Database Transactions ? Database
Ans. A dirty read occurs when a transaction is allowed to read data from a row that has been modified by another running transaction but not yet committed. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  database transaction Asked in 8 Companies Basic and Very Frequently asked. Ans. Polymorphism means the condition of occurring in several different forms.
Polymorphism in Java is achieved in two manners
1. Static polymorphism is the polymorphic resolution identified at compile time and is achieved through function overloading whereas
2. Dynamic polymorphism is the polymorphic resolution identified at runtime and is achieved through method overriding. Sample Code for overloading Sample Code for overriding Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  polymorphism  object oriented programming (oops)  oops concepts  oops concepts Asked in 108 Companies Basic   frequent Try 2 Question(s) TestVery frequently asked. Among first few questions in almost all interviews. Among Top 5 frequently asked questions. Frequently asked in Indian service companies (HCL,TCS,Infosys,Capgemini etc based on multiple feedback ) and Epam Systems Q9. Difference between == and .equals() ? Core Java
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory.
x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object.
Sample code:
String x = new String("str");
String y = new String("str");
System.out.println(x == y); // prints false
System.out.println(x.equals(y)); // prints true Sample Code for equals Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   string comparison   string   object class   ==   equals   object equality  operator   == vs equals   equals vs == Asked in 293 Companies basic   frequent Try 6 Question(s) TestVery frequently asked. Favorite question in Walk in Drive of many Indian service companies. Ans. Final variable is a variable constant that cannot be changed after initialization. Sample Code for final variable Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oops   java   final   final variable   basic interview question Asked in 12 Companies basic   frequent Try 1 Question(s) TestVery frequently asked. Favorite question in Walk in Drive of many Indian service companies. Ans. Its a method which cannot be overridden. Compiler throws an error if we try to override a method which has been declared final in the parent class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   final   final method Asked in 30 Companies basic   frequent Try 1 Question(s) TestAdvanced level question usually asked in High end product companies. Have been asked in Google and Amazon (Based on 1 Feedback) Q12. Describe, in general, how java's garbage collector works ? Core Java
Ans. The Java runtime environment deletes objects when it determines that they are no longer being used. This process is known as garbage collection. The Java runtime environment supports a garbage collector that periodically frees the memory used by objects that are no longer needed. The Java garbage collector is a mark-sweep garbage collector that scans Java dynamic memory areas for objects, marking those that are referenced. After all possible paths to objects are investigated, those objects that are not marked (i.e. are not referenced) are known to be garbage and are collected. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   garbage collection   java memory management   advanced Asked in 21 Companies intermediate   frequent Try 4 Question(s) TestFrequently asked. Favorite question in Walk in Drive of many Indian service companies. Q13. What are the methods of Object Class ? Core Java
Ans. clone() - Creates and returns a copy of this object.
equals() - Indicates whether some other object is "equal to" this one.
finalize() - Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
getClass() - Returns the runtime class of an object.
hashCode() - Returns a hash code value for the object.
toString() - Returns a string representation of the object.
notify(), notifyAll(), and wait() - Play a part in synchronizing the activities of independently running threads in a program. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   object class Asked in 16 Companies basic   frequent Try 1 Question(s) Test Q14. Difference between Abstract and Concrete Class ? Core Java
Ans. Abstract classes are only meant to be sub classed and not meant to be instantiated whereas concrete classes are meant to be instantiated. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   abstract classes   Abstract vs Concrete Class Asked in 1 Companies basic   frequent Very frequently asked. Usually asked with questions related to String. Frequently asked at CTS / Cognizant Ans. Object that can't be changed after instantiation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   immutable  immutability Asked in 27 Companies basic   frequent Try 2 Question(s) TestFrequently asked to fresh graduates. Ans. Process is a program in execution whereas thread is a separate path of execution in a program. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading   operating system   process vs thread Asked in 24 Companies basic   frequent Ans. ConcurrentHashMap is a hashMap that allows concurrent modifications from multiple threads as there can be multiple locks on the same hashmap. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashmap   map   concurrenthashmap   concurrenthashmap  concurrency   general electric   ge Asked in 32 Companies   rare Frequently asked at Manhattan Associates ( Based on 2 feedback ) Q18. What is a Lambda Expression ? What's its use ? Core Java
Ans. Its an anonymous method without any declaration.
Lambda Expression are useful to write shorthand Code and hence saves the effort of writing lengthy Code.
It promotes Developer productivity, Better Readable and Reliable code. Sample Code for lambda Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   lambda expression   architecture Asked in 58 Companies expert   frequent Try 1 Question(s) TestVery frequently asked. Usually followed by questions related to private constructor and synchronized access. Frequently asked in JPMorgan and TCS (Based on 2 feedback) Q19. Explain Singleton Design Pattern ? Design
Ans. http://www.buggybread.com/2014/03/java-design-pattern-singleton-interview.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   singleton   at&t   ebay  fidelity india  united healthcare india Asked in 46 Companies intermediate   frequent Frequently asked in face to face interviews. Q20. Write a program to print fibonacci series. Core Java
Ans. int count = 15;
int[] fibonacci = new int[count];
fibonacci[0] = 0;
fibonacci[1] = 1;
for(int x=2; x < count; x++){
fibonacci[x] = fibonacci[x-1] + fibonacci[x-2];
}
for(int x=0; x< count; x++){
System.out.print(fibonacci[x] + " ");
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ebay   fibonacci series Asked in 66 Companies basic   frequent