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.
Ans. Optional is to be used for arguments / atrributes which are indeed optional i.e the request should continue even if they aren't provided. It should not be used for mandatory attributes or arguments as we would like application to shout out ( with error message / exception trace ) to signify a problem.
Help us improve. Please let us know the company, where you were asked this question :
Q3. Does SQL allow null values ? Can we use it within Where clause ?
Ans. Yes , we can have null values for columns in SQL. Null value represent that the columns value is unknown or haven't been filled. Yes, We can use it within where clause to get the rows with null values.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Any reference in java that doesn't point to any object , gets assigned null i.e is a reference to null. Two object references in java are treated equal if they point to the same memory. That's Why null == null results true.
Help us improve. Please let us know the company, where you were asked this question :
Ans. whenever a reference is created in Java without assigning the object
like
String str;
It get's assigned to null. So null provides a temporary memory location which any reference can point to till an appropriate object is assigned. Moreover it denotes that nothing has been assigned yet and hence provides a check in many cases.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Null means nothing and hence means it's being assigned something till anything can be assigned to the reference. Null is a common memory location that get's assigned to any object reference till an actual object is assigned.
Empty object may not have a programmer initialized state but still a separate object in memory that has been assigned the placeholders.
Help us improve. Please let us know the company, where you were asked this question :
Ans. We can declare the reference as final to avoid reassignment but again we can always initialize the final reference to null. Even if there was any such facility available , it would have meant poor use of resources by assigning a new object in memory to each reference that's created. Many a times references are just meant to refer to other objects which already have a reference i.e sharing object by multiple references.
Help us improve. Please let us know the company, where you were asked this question :