Interview Questions and Answers - Order By Newest Ans. LinkedIn Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  event bubbling  events Asked in 1 Companies Q1832. What is event handling ? What is event propagation ? JavaScript
Ans. LinkedIn Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  event habdling  event propagation  events Asked in 1 Companies Q1833. Which of the following is valid greater than and equal to operator in Java ?
>=
=> Core Java
Ans. >=
=> will result in error.
=> somewhat looks like lambda operator "->" Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  operators  >= operator  greater than and equal to operator  comparison operators Q1834. If given a choice , which one would you prefer to send params to the Get service , path params or query param ? Web Service
Ans. If the number of params is quite large , I would prefer to either split it with majority of it in query params or all in query params.
If the params are all mandatory , I would keep it as path params. If it's optional , I would keep it as query param so as to keep consistent base url.
If we don't require the param name , then they can be kept as path params as query params necessitates the usage of param name. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Web Service  Get service  path vs query param  Rest  query param  path param Q1835. Is it necessary to specify "employeeId" with @PathParam("employeeId") in this case,
@Path("/{employeeId}")
public String employeeInfo(@PathParam("employeeId") Long employeeId){
} Rest
Ans. No, it's optional as the name of path param required is same as method param name in this case.
Even the declaration as following should work -
@Path("/{employeeId}")
public String employeeInfo(@PathParam Long employeeId){
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Web Service  Get service  Rest  path param Q1836. What happens when you assign a pre initialized reference some other object ? Core Java
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 : Like Discuss Correct / Improve  references  objects  garbage collection Asked in 1 Companies Q1837. What is Redis ? Redis
Ans. Redis is an in-memory data structure store, used as a database, cache and message broker. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  redis Q1838. What is replication in Redis ? why do we need it ? Redis
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 : Like Discuss Correct / Improve  Redis  replication in redis Asked in 1 Companies Q1839. What is the difference between Oracle , Cassandra and Redis ? Database
Ans. Oracle is a relational database. Cassandra is a noSQL Database whereas Redis is an inmemory cache. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oracle  casandra  redisAns. 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 : Like Discuss Correct / Improve  apache cassandra  cassandra Q1841. What are var args ?
or
What is the use of var args ? Core Java
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.
Declarations of methods with var args
void method(int... x){};
void method(int x, int... y){}; Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  var args  methods  functions   method declaration Asked in 2 Companies Q1842. Why following method declarations are not valid ?
void method(int... x, int y){};
void method(int... x,int... y){}; Core Java
Ans. Because var args are not only allowed with the last argument in the method declaration. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  var args  methods  functions   method declaration  ocjp  scjp Q1843. Which method will get called if we call it as method(1)
void method(int x ){};
void method(int... x){}; Core Java
Ans. Though the call an be bind to either of these but in this case, 1st method will get priority and hence will be called. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  var args  method  function  overloading  scjp  ocjp Q1844. Can we catch errors in Java ? Core Java
Ans. Yes we can
try {
// code
} catch (Error ex) {
// handling code
}
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 : Like Discuss Correct / Improve  exception handling  error handling  errors Asked in 1 Companies intermediate Q1845. Do you see any problem with this code
public class BuggyBread {
public static void main(String[] args) {
method("Hello","World");
}
private static void method(String... args){
for(String arg:args){
System.out.println(arg);
}
}
} Core Java
Ans. No, It will compile and execute perfectly fine. As we are using method with var args , we can call it with 0 to n arguments. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  var args  methods  method declarations  functions Q1846. Do you see any problem with this code
public class BuggyBread {
public static void main(String[] args) {
method();
}
private static void method(String... args){
for(String arg:args){
System.out.println(arg);
}
}
} Core Java
Ans. This will compile fine as we can provide 0 arguments for a var arg but will print nothing upon execution. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  var args  methods  method declarations  functions Q1847. Do you see any problem with this code
public class BuggyBread {
public static void main(String[] args) {
method("Hello");
}
private static void method(String... args){
for(String arg:args){
System.out.println(arg);
}
}
private static void method(String arg){
System.out.println(arg);
}
} Core Java
Ans. It will compile fine and the method call will bind to method with specific argument and not with var arg
i.e private static void method(String arg)
It will print "Hello" upon execution Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  var args  methods  method declarations  functions Q1848. Do you see any problem with this code
public class BuggyBread {
public static void main(String[] args) {
method("Hello");
}
private static void method(String... args){
for(String arg:args){
System.out.println(arg);
}
}
private static void method(String[] arg){
System.out.println(arg);
}
} Core Java
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 : Like Discuss Correct / Improve  var args  methods  method declarations  functions Q1849. Will this code work
public class BuggyBread {
public static void main(String[] args) {
method("Hello","World");
}
private static void method(String[] arg){
System.out.println(arg);
}
}
What all possible changes we can make to method signature to make it work ? Core Java
Ans. It won't work as java won't find the method definition for method with 2 arguments.
We can either declare the method as
private static void method(String arg,String arg2)
or
private static void method(String... arg) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  var args  methods  method declarations  functionsAns. It's an operating system file that maps IP address to host names. The hosts file assists the OS in addressing networked components and serves the function of translating human friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  host file  operating system Asked in 1 Companies Q1851. What is the order in which triggers gets fired ? Database
Ans. There is no specific order in which database fires the triggers if they are for the same operation. If we need to have a specific order for their execution, we should have them all in a stored procedure and the procedure should get executed upon the event. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  oracle  database  triggers  sequence of trigger execution  sequence in which triggers gets fired Asked in 1 Companies Q1852. How do you take screenshot in selenium? Selenium
Ans. TakeScreenshot th = TakeScreenshot(driver); //Enable the driver object to take screenshot
File src = th.getScreenShotAs(OutputType.FILE);
FileUtils.copyFilesrc("locationWhereUWantToPlaceTheScreenshot.jpg"); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  webdriver  selenium Asked in 1 Companies Q1853. What are the examples of immutable objects in Java ? Core Java
Ans. Following Classes in Java SE creates immutable objects
String class
Wrapper Classes like Integer, Float etc.
StackTraceElement
Most Enum classes
File Class
Locale Class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  immutable  immutability objects  immutable  immutability Asked in 1 Companies Basic   frequent Q1854. Can you give real time examples of thread or where thread are actually used ? Core Java
Ans. Games are very good examples of threading.You can use multiple objects in games like cars, motor bikes, animals, people etc. All these objects are nothing but just threads that run your game application. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  threads  multithreading Asked in 1 Companies Q1855. What is meant by the statement "Java is turing complete" ? Core Java
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  turing complete This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  type safety This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  lambda calculus Q1858. What is Type Inference ? Can you explain with respect to Java ? Core Java
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  type inference Q1859. What is meant by "Locality of Reference" or "Cache Locality" ? Core Java
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Cache Locality  Locality of Reference Q1860. What is dynamic dispatch in Java ? Core Java
Ans. Dynamic dispatch in java is also known as runtime polymorphism.It is a process in which a call to an overriden method is resolved at runtime. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  dynamic dispatch  runtime polymorphism  object oriented programming (oops)  oops concepts