Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers for 'Hewlett packard (hp)' - 10 question(s) found - Order By Rating | ||||
| ||||
Ans. Factory Design Patterns is the pattern that recommends creation of separate Factory Object for creation of other object. So its like saying - If you want to create an object of ClassA, Talk to FactoryObject ( which is an object of FactoryClass ). FactoryObject in itself encapsulates the inputs and logic required to make the decision regarding the creation and construction of object. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  design pattern  factory design pattern Asked in 9 Companies | ||||
| ||||
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 | ||||
| ||||
Ans. public void checkIfAnagram(String str1,String str2){ boolean anagram = true; for(char c:str1.toCharArray()){ if(!str2.contains(String.valueOf(c))){ System.out.println("Strings are Anagrams"); anagram = false; } if(anagram == true){ System.out.println("Strings are not Anagrams"); } } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   check if 2 strings are Anagrams Asked in 30 Companies basic   frequent | ||||
| ||||
Ans. [Open Ended Answer] This is a very sensitive question and should be dealt with caution. Just simply saying that you never had any disagreement will present you as dumb team member. Showing your self as too aggressive in such decisions will present you as a trouble maker. You should present a situation where you had an argument / disagreement but eventually you and your team mates mutually found a way out of it. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 20 Companies basic | ||||
| ||||
Ans. Declaration is intimation to the compiler about the nature of Data a reference is going to hold. For example - List myList; Instantiation is reservation of memory. For example myList = new ArrayList(); Initialization or construction is setting the default values for member elements. For example myList = new ArrayList(mySet); ** Example 2nd is both for instantiation as well as initialization. The only difference is that 2nd will initialized the member elements to their default values whereas 3rd will initialized it with the elements from set. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  declaration   instantiation   initialization   construction   declaration vs instantiation   instantiation vs initialization   declaration vs initialization Asked in 1 Companies basic   frequent | ||||
Frequently asked in Cognizant (CTS) | ||||
| ||||
Ans. Storing the state of an object in a file or other medium is called serialization. Classes can communicate only if they are built together ( as they need Byte code for communication ). What if we need to enable communication between different applications ( i.e they have been built independently or even they reside at different locations ), We need a mechanism that will transfer the Bean state to a Medium than can be transferred to the receiving application. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   oops   serialization Asked in 18 Companies basic   frequent | ||||
Try 1 Question(s) Test | ||||
| ||||
Ans. Yes, We can call garbage collector directly but it doesn't guarantees that the gc will start executing immediately. This gc( ) method appears in both Runtime and System classes of java.lang package. | ||||
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   jvm   gc   yes no Asked in 4 Companies expert | ||||
Try 1 Question(s) Test | ||||
| ||||
Ans. co-variant return type states that return type of overriding method can be subtype of the return type declared in method of superclass. it has been introduced since jdk 1.5 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   oops   inheritence   overriding   covariant return type   jdk5   advanced Asked in 3 Companies expert | ||||
| ||||
Ans. Inner join is the intersection of two tables on a particular columns whereas Outer Join is the Union of two tables. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  sql   joins   inner join   outer join Asked in 4 Companies basic   frequent | ||||
| ||||
Ans. The goal of a synchronised block is to achieve mutual exclusion i.e at one time, the segment of the code should be executed by single thread only and hence the lock needs to be retrieved before executing the segment and then released. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  synchronized block   synchronized   synchronization   multithreading   threads   mutual exclusion   concurrency Asked in 4 Companies intermediate   frequent | ||||
Try 1 Question(s) Test | ||||