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 'Robert bosch india' - 2 question(s) found - Order By Rating | ||||
| ||||
Ans. Assigning a value of one type to a variable of another type is known as Type Casting. Example : int x = 10; byte y = (byte)x; In Java, type casting is classified into two types, Widening Casting(Implicit) widening-type-conversion and Narrowing Casting (Explicitly done) narrowing-type-conversion. Widening or Automatic type converion - Automatic Type casting take place when,the two types are compatible and the target type is larger than the source type Example : public class Test { public static void main(String[] args) { int i = 100; long l = i; //no explicit type casting required float f = l;//no explicit type casting required System.out.println("Int value " i); System.out.println("Long value " l); System.out.println("Float value " f); } } Narrowing or Explicit type conversion - When you are assigning a larger type value to a variable of smaller type, then you need to perform explicit type casting. Example : public class Test{ public static void main(String[] args) { double d = 100.04; long l = (long)d; //explicit type casting required int i = (int)l;//explicit type casting required System.out.println("Double value " d); System.out.println("Long value " l); System.out.println("Int value " i); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  typecasting  type casting Asked in 23 Companies | ||||
Related Questions | ||||
Very frequently asked. Usually followed by questions related to private constructor and synchronized access. Frequently asked in JPMorgan and TCS (Based on 2 feedback) | ||||
| ||||
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 | ||||
Related Questions | ||||
Difference between Static and Singleton Class ? | ||||
What is the difference between Singleton and Prototype Bean scope in Spring ? | ||||
serialization and deserialization of singleton class | ||||
What is the difference between these two approaches of creating singleton Class ? //Double Checked Locking Code public static Singleton createInstance() { if(singleton == null){ synchronized(Singleton.class) { if(singleton == null) { singleton = new Singleton(); } } } return singleton; } //Single checked locking code public static Singleton createInstance() { synchronized(Singleton.class) { if(singleton == null) { singleton = new Singleton(); } } return singleton; } | ||||
What are design situations to use Singleton and Prototype Design Pattern ? | ||||
How to avoid cloning, serialization in the singleton class ? | ||||
When singleton can break and how to resolve it | ||||
If you are given choice to either load object eagerly or lazily , which one would you use in case of singleton pattern ? | ||||
When should we use prototype scope and singleton scope for beans ? | ||||