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. void is a return type which indicates that the method returns nothing but returns the control to the line next to the method call. All methods need to have a return type and hence a method returning nothing needs to be declared void.
Help us improve. Please let us know the company, where you were asked this question :
Ans. All methods are not expected to return something but Yes, all methods are expected to have a return type. If a method returns nothing, it can be declared with the return type void.
Constructors are not expected to have any return types , not even void.
Help us improve. Please let us know the company, where you were asked this question :
Ans. BuggyBread method without any return type is the constructor which get's called upon object creation whereas BuggyBread method with return type of void is just another method that needs to be called explicitly for it's invocation.
Help us improve. Please let us know the company, where you were asked this question :
Ans. No, first method is a constructor whereas the second method is just a normal method. There is no way a constructor can be called explicitly and hence all explicit calls to BuggyBread() would result in compilation error.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Object is an entity in Java , i.e which has a state ( instance variables ) and methods attached to it ( static or non static , through class definition ). References are the identifiers that are used to point to objects.
For example -
Employee emp = new Employee();
emp = new Employee();
In this code, emp is the reference that gets assigned to the new object created by the new operator. In the second line , we have assigned the same reference to another object. So with these 2 lines of code, we have 2 objects in memory with reference emp now pointing to second object.
Help us improve. Please let us know the company, where you were asked this question :
Ans. These are the platforms or set of services provided by Amazon for cloud services , database storage , content delivery and other business applications and solutions.
Help us improve. Please let us know the company, where you were asked this question :
Ans. There are 2 ways to specify dependencies in Spring, one by the way of specifying beans in config files and other is by specifying annotations like @Bean, @Component , @Service etc to let spring know of the dependencies.
Help us improve. Please let us know the company, where you were asked this question :
Ans. assertThat is introduced with Junit4 and offers many advatanges over assert. Messages are more explanatory, offer better type safety and are more readable. Moreover hamcrest library is portable as it can used both with junit and TestNG.Moreover assertThat provides flexibility as the same method can be used for assert , assertEquals,assertTrue etc through the use of matcher methods.
Help us improve. Please let us know the company, where you were asked this question :
Q1723. Which of following is / are valid static final declaration ?
public static final String MAX_NUM = "10";
public static final Object NULL = null;
public static final MathContext MATH_CONTEXT = new MathContext(2,RoundingMode.CEILING);
Ans. Now the reference points to a new object in memory. If that was the only reference for the previous object , it will be marked for garbage collection.
Foe example -
Object obj = new Object();
obj = new Object();
object created in first line will be eligible for garbage collection after line 2 as it looses all it's handlers.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Asynchronous Replication of information from master to all slaves. Redis is an in memory storage and hence any crash may result in complete loss of information on a cluster.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Apache Cassandra is a free and open source distributed NoSQL database management system designed to handle large amounts of data providing high availability with no single point of failure.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Var args is the feature of Java that allows a method to have variable number of arguments. Var args are used when we are not sure about the number of arguments a method may need. Internally java treats them as array.
but we shouldn't ideally do that as errors are mostly JVM based and not application based and there is rarely we can do something about it. Very likely catching and not re throwing would lead to muting their response or trace.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Yes, it will give compilation error and java will complain about duplicate method. Java treat var args internally as arrays and hence would result in same byte code for both method's syntax.
Help us improve. Please let us know the company, where you were asked this question :