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. It will give compile time error saying "The final field array.length cannot be assigned" Arrays once initialized cannot be resized. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. No. But It will throw ArrayStoreException at runtime. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Assigning a value of one type to a variable of another type is known as Type Casting. Example : int x = 10; byte y = (byte)x; In Java, type casting is classified into two types, Widening Casting(Implicit) widening-type-conversion and Narrowing Casting (Explicitly done) narrowing-type-conversion. Widening or Automatic type converion - Automatic Type casting take place when,the two types are compatible and the target type is larger than the source type Example : public class Test { public static void main(String[] args) { int i = 100; long l = i; //no explicit type casting required float f = l;//no explicit type casting required System.out.println("Int value " i); System.out.println("Long value " l); System.out.println("Float value " f); } } Narrowing or Explicit type conversion - When you are assigning a larger type value to a variable of smaller type, then you need to perform explicit type casting. Example : public class Test{ public static void main(String[] args) { double d = 100.04; long l = (long)d; //explicit type casting required int i = (int)l;//explicit type casting required System.out.println("Double value " d); System.out.println("Long value " l); System.out.println("Int value " i); } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Yes wef from Java 9 | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. yes, Java is a class-based and object-oriented programming language. It is a platform-independent language i.e. the compiled code can be run on any java supporting platform. It runs on the logic of “Write once, run anywhere”. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. The Aadhaar enabled Payment System or AePS | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Both provide the thread safety but the actual difference come when talk about performance. CHM gives best performance when no of writer threads are less in number. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. We can schedule that through CloudWatch. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. ExceptionHandler is Used to handle at Method level | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Creating an index creates a separate table. ... Indexes are used to speed the search of data within tables. Partitions provide segregation of the data at the hdfs level, creating sub-directories for each partition. Partitioning allows the number of files read and amount of data searched in a query to be limited | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Every fresh session having its own cache memory, Caching is a mechanism for storing the loaded objects into cache memory. The advantage of cache mechanism is, whenever again we want to load the same object from the database then instead of hitting the database once again, it loads from the local cache memory only, so that the no. of round trips between an application and a database server got decreased. It means caching mechanism increases the performance of the application. In hibernate we have two levels of caching First Level Cache [ or ] Session Cache Second Level Cache [ or ] Session Factory Cache [ or ] JVM Level Cache | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. No, its usually not done. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Layer 7 - Application Layer 6 - Presentation Layer 5 - Session Layer 4 - Transport Layer 3 - Network Layer 2 - Data Link Layer 1 - Physical | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Collections in Java is nothing but a library implementation for data structures and algorithm. If it's not available , we might have to include some other library or provide our own implementation. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. table per hierarchy table per concrete class table per sub class | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. package snippet; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; public class Pascal { public static void main(String[] args) { System.out.println(generatePascalTriangle(5)); } static Map> generatePascalTriangle(int size) { Map> triangle = new HashMap<>(); triangle.put(0, Arrays.asList(1)); triangle.put(1, Arrays.asList(1, 1)); for (int i = 2; i <= size; i ) { List coeffListForI = new ArrayList<>(); List coeffListForI_1 = triangle.get(i - 1); coeffListForI.add(1); for (int j = 0; j <= coeffListForI_1.size() - 2; j ) { coeffListForI.add(coeffListForI_1.get(j) coeffListForI_1.get(j 1)); } coeffListForI.add(1); triangle.put(i, coeffListForI); } return triangle; } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. It depends on how we are serializing. The Serialization API doesn't worry about private variables and convert it into binary representation. If we are using a library to map it to JSON / XML using XML Mappers, it may create trouble. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. @RequestMappping | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. As Edge location only host cached content, Amazon CDN service or CloudFront is provided on these locations. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. import java.util.Random; public class OTPGenerator { public static void main(String[] args) { int otpLength = 4; String otp = generateOTP(otpLength); System.out.println("Generated OTP: " otp); } private static String generateOTP(int length) { StringBuilder otp = new StringBuilder(); Random random = new Random(); for (int i = 0; i < length; i ) { int digit = random.nextInt(10); otp.append(digit); } return otp.toString(); } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. At that bucket, it will form a linked list depending on what equals method evaluates for that object. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Disaster Recovery and availability | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Saving Cost by either expiring objects or moving to low cost storage. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Through Snapshots | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. US-EAST-1 | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. List is an interface whereas ArrayList is an implementation of List. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. Following are key differences between containers and serverless: Supported host environments: Containers can run on any modern Linux server, as well as certain versions of Windows. In contrast, serverless runs on specific host platforms, most of which are based in the public cloud (like AWS Lambda or Azure Functions). Self-servicing ability. For the reasons just noted, in most cases, serverless functions require you to use a public cloud. (There are on-premises serverless frameworks, like Fn, but these are not yet widely used.) With containers, you can set up your own on-premises host environment, or use a public cloud service like ECS. Cost. Because serverless environments are hosted in the cloud, you have to pay to use them. In contrast, you can set up a container environment yourself using open source code for free (although you’ll still have management costs, of course). Supported languages. You can containerize an application written in any type of language as long as the host server supports the language. Serverless frameworks are different; they support a limited number of languages. The details of supported serverless language vary from serverless platform to platform. Statefulness. Most serverless platforms are designed to support stateless workloads. (Some serverless providers offer limited support for stateful services; cf. Durable Functions on Azure.) Although you can connect to external storage services (like S3 on AWS) from within serverless platforms, the functions themselves cannot be stateful. Containers present their own persistent storage challenges, but creating stateful containerized apps is certainly possible. Availability. Serverless functions are designed to run for a short period—usually, a few hundred seconds—before they shut down. Containers can run for as long as you need. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
| ||||
Ans. Inline functions , just like C++ Macros is an optimized technique used by compiler to reduce the execution time. If the function is working on pre identified values ( which aren't resolved at runtime ), the function can execute the method and evaluate the outcome at compile time only instead of making a function call at runtime. In Java, the optimizations are usually done at the runtime or JVM level. At runtime, the JVM perform some analysis to determine which methods to inline. Java compiler would never inline any method and there is no way in java for the developer to explicitly define inlining of methods as it's take intrinsically care of during runtime only. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() ![]() | ||||