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 'Time' - 29 question(s) found - Order By Newest | |||||||||||
Very frequently asked. Among first few questions in almost all interviews. Among Top 5 frequently asked questions. Frequently asked in Indian service companies (HCL,TCS,Infosys,Capgemini etc based on multiple feedback ) and Epam Systems | |||||||||||
| |||||||||||
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory. x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object. Sample code: String x = new String("str"); String y = new String("str"); System.out.println(x == y); // prints false System.out.println(x.equals(y)); // prints true | |||||||||||
Sample Code for equals | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   string comparison   string   object class   ==   equals   object equality  operator   == vs equals   equals vs == Asked in 294 Companies basic   frequent | |||||||||||
Try 6 Question(s) Test | |||||||||||
| |||||||||||
Ans. OOPs or Object Oriented Programming is a Programming model which is organized around Objects instead of processes. Instead of a process calling series of processes, this model stresses on communication between objects. Objects that all self sustained, provide security by encapsulating it's members and providing abstracted interfaces over the functions it performs. OOP's facilitate the following features 1. Inheritance for Code Reuse 2. Abstraction for modularity, maintenance and agility 3. Encapsulation for security and protection 4. Polymorphism for flexibility and interfacing | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  oops  oops features Asked in 260 Companies basic   frequent | |||||||||||
| |||||||||||
Ans. 1. Overriding method can not be more restrictive than the overridden method. reason : in case of polymorphism , at object creation jvm look for actual runtime object. jvm does not look for reference type and while calling methods it look for overridden method. If by means subclass were allowed to change the access modifier on the overriding method, then suddenly at runtime when the JVM invokes the true objects version of the method rather than the reference types version then it will be problematic 2. In case of subclass and superclass define in different package, we can override only those method which have public or protected access. 3. We can not override any private method because private methods can not be inherited and if method can not be inherited then method can not be overridden. | |||||||||||
Sample Code for Overriding | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   overriding   access specifier   inheritence   oops   polymorphism  object oriented programming (oops)  oops concepts   runtime polymorphism  object oriented programming (oops)  oops concepts Asked in 4 Companies | |||||||||||
Try 2 Question(s) Test | |||||||||||
Basic and Very Frequently asked. | |||||||||||
| |||||||||||
Ans. Polymorphism means the condition of occurring in several different forms. Polymorphism in Java is achieved in two manners 1. Static polymorphism is the polymorphic resolution identified at compile time and is achieved through function overloading whereas 2. Dynamic polymorphism is the polymorphic resolution identified at runtime and is achieved through method overriding. | |||||||||||
Sample Code for overloading Sample Code for overriding | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  polymorphism  object oriented programming (oops)  oops concepts  oops concepts Asked in 108 Companies Basic   frequent | |||||||||||
Try 2 Question(s) Test | |||||||||||
Almost sure to be asked in every company using any Dependency Injection framework ( Spring, Guice etc ) | |||||||||||
| |||||||||||
Ans. It is a Design Pattern that facilitates loose coupling by sending the dependency information ( object references of dependent object ) while building the state of the object. Objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally and hence provide better flexibility. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  design patterns   ioc ( Inversion of Control )  dependency injection Asked in 83 Companies intermediate   frequent | |||||||||||
Very frequently asked.Usually among first few questions. | |||||||||||
| |||||||||||
Ans. MVC is a Design Pattern that facilititates loose coupling by segregating responsibilities in a Web application 1. Controller receives the requests and handles overall control of the request 2. Model holds majority of the Business logic, and 3. View comprise of the view objects and GUI component | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  j2ee   mvc   mvc design pattern   design pattern   struts   spring   web application   web frameworks   ebay Asked in 60 Companies basic   frequent | |||||||||||
Try 1 Question(s) Test | |||||||||||
| |||||||||||
Ans. Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode into instructions that can be sent directly to the processor. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   compiler   jvm   bytecode   justintime compiler   architecture | |||||||||||
Usually asked to entry level software developers. | |||||||||||
| |||||||||||
Ans. public static void main(String[] args) { int num1 = 1; int num2 = 2; num1 = num1^num2; num2 = num1^num2; num1 = num1^num2; System.out.print("num1 = " + num1 +", num2 = "+num2); } | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  code  coding Asked in 37 Companies basic   frequent | |||||||||||
| |||||||||||
Ans. Yes, we can do that. Compiler wont complain. But using object reference we can only access methods which have been defined for object class i.e clone(), equals(), hashCode(), toString() etc. We cannot access methods defined in String class or in any class in hierarchy between String and Object. For example - we cannot do obj.append("abc") as it will now give compile time error. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  object initialization  object declaration   runtime polymorphism  object oriented programming (oops)  oops concepts | |||||||||||
Frequently asked to fresh graduates. | |||||||||||
| |||||||||||
Ans. When a object invokes yield() it returns to ready state. But when an object invokes sleep() method enters to not ready state. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   threads   multi threading   yield   sleep   scheduling   operating system Asked in 4 Companies basic   frequent | |||||||||||
| |||||||||||
Ans. JProbe, OptimizeIt | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   tools   jvm   memory management   memory leaks   jprobe   optimeit   architecture   technical lead | |||||||||||
| |||||||||||
Ans. The Exception class has two main subclasses : IOException class and RuntimeException Class. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   exceptions   exception class   ioexception   runtimeexception | |||||||||||
| |||||||||||
Ans. http://www.buggybread.com/2015/02/java-util-date-time-classes-and.html | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   util   java.util.date   time | |||||||||||
| |||||||||||
Ans. To avoid ClassCastException. Though the following code will compile fine but will result in ClassCastException during runtime. Fruit fruit = new Apple(); Banana banana = Banana(fruit); // ClassCastException This code will not give compile time error as Banana and Fruit are related as Banana either extends or implement Fruit, So downcasting is acceptable. With this code we assume that the Fruit handler will have the Apple object at that point, violating which the code will throw the exception. This exception can be avoided by following code. Fruit fruit = new Apple(); if(fruit instanceOf Banana){ Banana banana = Banana(fruit); // ClassCastException } | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   instanceof   classcastexception   runtime exceptions  instanceOf operator | |||||||||||
Try 2 Question(s) Test | |||||||||||
| |||||||||||
Ans. Static methods are resolved during compile time and hence they cannot participate in runtime polymorphism. Instance methods are resolved during runtime. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   static methods   methods   runtime polymorphism intermediate | |||||||||||
Ans. Runtime Polymorphism | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  static class   static vs singleton   java   oops   objects  Runtime Polymorphism | |||||||||||
| |||||||||||
Ans. This class is used to provide access to the Java runtime system | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  runtime class  jre  java runtime | |||||||||||
| |||||||||||
Ans. hh= hours in 1-12 format HH= hours in 0-23 format kk = Hours in 1-24 format KK= hours in 0-11 format | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Date  Date Time Format  Date Time | |||||||||||
| |||||||||||
Ans. TimeBasedRollingPolicy enables rolling of logs based on the time / days whereas SizeBasedTriggeringPolicy enables rolling of logs based on size cap. Yes we can use both together. In that case Logs will be rolled in case any of the condition is met i.e after the interval or if the size is reached. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Log4j  TimeBasedRollingPolicy  SizeBasedTriggeringPolicy | |||||||||||
| |||||||||||
Ans. dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. This is used to achieve runtime polymorphism in java. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  overriding  runtime polymorphism  object oriented programming (oops)  oops concepts | |||||||||||
| |||||||||||
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 | |||||||||||
| |||||||||||
Ans. Latency is the delay incurred while communicating a message i.e the time took the message in transit over network. processing time is the delay it took for the server to process the request. Response time is the sum total of latency and processing time. For example - Let's say it takes 1 ms for the request to reach from client to server and similar 1 ms for the response to come back to client. Moreover it takes approx 10 ms for the application to process the request. So The response time would be outward latency + processing time + inward latency = 12 ms | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  latency   response time   processing time | |||||||||||
| |||||||||||
This question was recently asked at 'Intime Tec'.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   Asked in 1 Companies | |||||||||||
| |||||||||||
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  Data Stricture   Big O Notation  time complexity | |||||||||||
| |||||||||||
Ans. Yes, Runtime Polymprohism requires either Class inheritance or Interface implementation. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  runtime polymorphism  object oriented programming (oops)  oops concepts  method overriding  inheritance  object oriented programming (oops)  oops concepts | |||||||||||
| |||||||||||
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  vtable  virtual method table   method overriding  runtime polymorphism  object oriented programming (oops)  oops concepts | |||||||||||
| |||||||||||
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  virtual method table   method overriding  runtime polymorphism  object oriented programming (oops)  oops concepts expert   rare | |||||||||||
| |||||||||||
Ans. There is one VTable for each class. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  virtual table method  vtable  runtime polymorphism  object oriented programming (oops)  oops concepts   method overriding intermediate   rare | |||||||||||
| |||||||||||
Ans. Time Slicing is the process to divide the available CPU time to the available runnable threads. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Time Slicing  threads  thread scheduling   thread scheduler | |||||||||||
| |||||||||||