Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers - Order By Newest | ||||
![]() ![]() | ||||
| ||||
Ans. Because Abstract class is incomplete i.e there are abstract methods that needs to be defined by extending classes. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Frankly saying I dont see much use of method overloading as its just little design convenience as you can use the same name but still have binding to different methods depending on the need. Method overriding is really important and is much more useful than method overloading. Along with other programming concepts like interfaces and dependency injection , it facilitates the development of software as libraries and plug-gable components. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Keywords are the reserved words that have a pre defined meaning for a compiler whereas modifiers are the type of keywords that modifies the state or definition of a programming construct. for, while are keywords but not modifiers. private , public , final , abstract etc are keywords as well as modifiers. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. SOAP services are better in case we need to establish a formal and detail contract with the client or callers and hence suitable for 1. Services published for much wider unknown audience 2. Require large input payload 3. Requiring different level for authentication | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Keywords are the reserved words that have a pre defined meaning for the compiler and hence are restricted to be used as identifiers. Identifiers are the name assigned to different programming constructs like classes, interfaces, methods , variables etc. Literals are the values that are assigned to Identifiers. For example int count = 0; in the above statement "int" is a keyword, "count" is an identifier and "0" is a literal | ||||
![]() ![]() ![]() | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Java identifies the method to be called at runtime by the object that is being referenced. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Authentication / Authorization URL forwarding Auditing / Logging Localization | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Eclipse Vert.x is a tool kit for building reactive applications on the JVM. Vert.x is event driven and non blocking. This means the application can handle lot of concurrency using a small number of kernel threads. Vert.x lets the application scale with minimal hardware. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Both will produce the same output but 1st will consume more resources in terms of memory ( for maintaining intermediate value ) and computing power ( as single mathematical calculation with more operands is more effective than multiple calculations with broken down operands ) | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Yes, doesn't provide exclusive access as we cannot allocate and deallocate memory exclusively as Java internally manages it. The advantage of this is that it relieves the coder for such tasks and helps protect from many bugs that may get introduced with imperfect coding. Moreover as java garbage collector collects all unclaimed memory or objects, it helps the application from memory leaks. On the flip side , as coder doesn't have extensive excess to memory , it is upto java to decide on the state for programming construct and data storage and hence may introduce some security risks. For example - Java keeps string literals in string pool and there is no exclusive way to remove it and hence may stay and sensitive data in string pool may introduce security issues. Moreover when we overwrite a value or object for a variable / reference, it is upto java to purge those values and hence it may stay in memory for a while till java decide that it is no longer referenced and hence should be removed and hence makes it vulnerable for inappropriate access. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
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. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Though var args are used rarely but they are pretty useful if a method is expected to receive variable number of arguments. For example - it's pretty useful for the main method as the caller has the flexibility to provide arguments in infinite ways.It provides a convenience and flexibility to the caller. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Web Server and Worker | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. It means that only 1 thread can access have access to Vector at a time and no parallel access is allowed whereas Array List allows parallel access by multiple threads. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. No, only methods can be declared protected. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Strings are immutable in Java and not final. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class LinkedList { Node start = null; Node head = null; class Node { Integer body; Node nextNode; Node(Integer value) { body = value; } } private void addNodeToEnd(Integer value) { if (start == null) { start = new Node(value); head = start; head.nextNode = null; return; } while (head.nextNode != null) { head = head.nextNode; } head.nextNode = new Node(value); } private void traverse() { head = start; while (head != null) { System.out.println(head.body); head = head.nextNode; } } public static void main(String[] args) { LinkedList ll = new LinkedList(); ll.addNodeToEnd(5); ll.addNodeToEnd(10); ll.addNodeToEnd(15); ll.traverse(); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. public class LinkedList { Node start = null; Node head = null; class Node { Integer body; Node nextNode; Node(Integer value) { body = value; } } private void addNodeToEnd(Integer value) { if (start == null) { start = new Node(value); head = start; head.nextNode = null; return; } while (head.nextNode != null) { head = head.nextNode; } head.nextNode = new Node(value); } private void deleteNode(Integer value) { head = start; while (head.nextNode != null) { if(head.nextNode.body == value){ head.nextNode = head.nextNode.nextNode; } head = head.nextNode; } } private void traverse() { head = start; while (head != null) { System.out.println(head.body); head = head.nextNode; } } public static void main(String[] args) { LinkedList ll = new LinkedList(); ll.addNodeToEnd(5); ll.addNodeToEnd(10); ll.addNodeToEnd(15); ll.traverse(); ll.deleteNode(10); ll.traverse(); } } | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. 65 to 90 for capital case alphabets 97 to 122 for lower case alphabets | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. pop method pulls the top element from the stack and then move the top to the next element whereas peek only get the top element but doesn't move the top. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. By using synchronized static method or synchronized block | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. String s1 = "akhilesh"; char[] ch = s1.toCharArray(); for (int i = ch.length-1 ; i >=0 ; i--) { System.out.print(ch[i]); } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Abstraction is a process of hiding the implementation details and describing only the functionality to the user. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. LinkedList maintains the insertion order in collection. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. In terms of compute options and configurations, Reserved Instances and On Demand instances are the same. The only difference between the two is that a Reserved Instance is one you rent (reserved) for a fixed duration, and in return you receive a discount on the base price of an On Demand instance. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. private void permutation(String prefix, String sufix) { int ln = sufix.length(); if(ln == 0) { System.out.println(prefix); } else { IntStream.range(0, ln).forEach(i->permutation(prefix sufix.charAt(i), sufix.substring(0,i) sufix.substring(i 1, ln))); } } call:permutation("", "abcdef"); | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. We can create API gateway and give the name of lambda function in order to be linked with lambda function, deploy the API and whenever request will be made from API it will directly be linked to lambda function to perform further process. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Java could design it in such a manner but would result in ambiguity if there are multiple files with the same name. The only way to get over it to show the message when you use any such class to provide explicit import with the package prefix. The other problem could be that Java might have to change the early import to Late import and check what's being used to decide what needs to be imported as otherwise you will see errors regarding the ambiguous imports with duplicate file name. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Encapsulation facilitate hiding and restricted access and hence more of a security feature. Encapsulation is definitely a great feature as when applications expand criss cross communication between objects / modules could lead to blunders. Inheritance facilitates code reuse. Polymorphism comprise of method overloaded ( which to me is negligible usage ) and method overriding. Method overriding is of great usage as it facilitates concept of interfaces and plugin development. So it’s Security / Organization vs Code Reuse / Support for other features like overriding vs Contracts / Plugin Development facilitating the creation of frameworks / libraries. Which is more important may vary from application to application , its scale , its use , its sensitivity etc. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. No. The whole idea of default method is to provide a default definition in case the implementing class intend to provide definition for only some of the methods. Making any of the interface method private would restrict it from being implemented by the implementing class. So default method is an option to provide implementation and not restricting a new definition. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() ![]() | ||||