InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 451. |
List the different types of classloaders in java. |
|
Answer» There are 3 types of built-in Class Loaders:
|
|
| 452. |
What do you mean by Classloader in Java? |
|
Answer» Class loaders HELP in loading classes during RUNTIME to the Java VIRTUAL Machine. In ADDITION, they are part of the Java Runtime Environment. Hence, due to class loaders, JVM is not required to know the underlying files for running PROGRAMS. |
|
| 453. |
What do you mean by inner class in java? Explain |
|
Answer» It is a CLASS that is a MEMBER of ANOTHER class. There are 4 TYPES of INNER classes:
|
|
| 454. |
What do you mean by Java Annotations? |
|
Answer» Annotation is a tag in Java that represents metadata attached with a class, METHOD, interface, or field. It PROVIDES supplement information to be used by compiler and JVM. Annotations do not change a COMPILED program's action and they are not pure comments. If you are preparing for interviews, you can check core java interview questions and answers for more insight. |
|
| 455. |
Explain the difference between abstract class and interface in Java? |
||||||||||||
Answer»
It is an interfaces that has no FIELD or methods (empty interface). It helps in conveying to the JVM that the class that is implementing the interface of a category will have special BEHAVIOR. It is also known as TAG interface. There are 4 major marker interfaces:
|
|||||||||||||
| 456. |
What is an interface in Java? Explain |
|
Answer» It is a reference type that is similar to a CLASS in Java. It is a COLLECTION of abstract METHODS that is used for full abstraction. An interface may have methods and VARIABLES but the methods in interface are abstract by default. |
|
| 457. |
What is static import in Java? Explain |
|
Answer» The static import feature allows the static member of a CLASS to be accessed directly without USING the qualified NAME. The biggest advantage of this feature is that less coding will be REQUIRED if you have access to a static member. |
|
| 458. |
Explain access modifiers in Java. |
|
Answer» Access MODIFIERS HELP to restrict the SCOPE of a class, variable, constructor, method or data. Four TYPES of access modifiers are available:
|
|
| 459. |
What is the purpose of main function in Java? |
|
Answer» From version JDK6 onwards, the MAIN method is mandatory to START code execution. If your program does not contain "main" method, you will get a run-time error. PLEASE note that in the absence of "main" method your entire program will SUCCESSFULLY COMPILE but it will throw an error at runtime. |
|
| 460. |
What is difference between classpath and path variables in Java? |
|||||||||
Answer»
|
||||||||||
| 461. |
Why Java is called not pure Object Oriented language? |
|
Answer» Java is not a pure OOP language as it USES PRIMITIVE datatypes such as int float char double. A pure OOP language should use nothing but OBJECTS, and everything should be a CLASS. But in Java, not everything is a class, such as byte, int, float, char, etc. This is the REASON Java is a not a pure OOP language. |
|
| 462. |
Why does Java does not support multiple inheritance? Explain |
|
Answer» Java does not support MULTIPLE inheritances because it may lead to overriding of methods when extended classes have the same METHOD names. Also, supporting multiple inheritances through classes may give RISE to ambiguity errors. However, multiple inheritance is POSSIBLE through the INTERFACE. |
|
| 463. |
Explain the difference between JVM and JRE? |
||||||||||||
Answer»
|
|||||||||||||
| 464. |
Explain the difference between JDK and JVM? |
||||||||||||
Answer»
|
|||||||||||||
| 465. |
What is JVM? |
|
Answer» A part of Java Run Environment (JRE), JVM is a virtual machine that provides runtime environment to drive Java programs or APPLICATIONS. It ASSISTS in converting bytecode into machine language and handles system memory. |
|
| 466. |
List some important features of Java 10 release? |
|
Answer» Here are some of the most important Java 10 FEATURES:
|
|
| 467. |
List some OOPS Concepts in Java? |
|
Answer» In JAVA, there are 10 OOPS CONCEPTS as FOLLOWS:
|
|
| 468. |
What is the substitute of Rhino Javascript engine in Java 8? |
| Answer» | |
| 469. |
How to create a Base64 decoder in Java8? |
| Answer» | |
| 470. |
What is type inference in Java8? |
|
Answer» Type inference is a FEATURE of Java that GIVES the CAPABILITY to the compiler to SEEM at each method invocation and corresponding announcement to determine the type of arguments. Java PROVIDES multiplied model of type inference in Java eight |
|
| 471. |
What do you mean by chromounits in java8? |
|
Answer» The Chrono UNIT was added in Java 8 to replace those integer VALUE that was USED in OLD API to represent the MONTH, day, year, etc. unit is defined in the java.time.temporal.ChronoUnit |
|
| 472. |
Explain local datetime API in Java8? |
|
Answer» In new data-time API, one of the CLASS is LOCAL Date-Time API where there is no problem of handling of the time-zones. PROGRAMMERS use this API where time zones are not REQUIRED. Local Date-Time API is defined in the package java.time |
|
| 473. |
What do you mean by collectors in Java 8? |
|
Answer» Collectors perform the reduction OPERATIONS. It combines the result of the PROCESSING ongoing on the elements of the STREAM like collecting the elements into collections, summarizing the elements according to the DIFFERENT CRITERIA. Collectors return the list or a string. As a result, the readability is increased. Static import used here is static import java.util.stream.Collectors.*; |
|
| 474. |
What is sequential and parallel stream in Java 8? |
|
Answer» Parallel streams divide the provided venture into many and run them in unique threads, MAKING use of a couple of cores of the computer. On the other hand, sequential streams WORK just like for-loop the use of a single core. The DUTIES supplied to the streams are generally the ITERATIVE operations PERFORMED on the factors of a series or array or from different dynamic sources. Parallel execution of streams run more than one iterations concurrently in extraordinary accessible cores. |
|
| 475. |
Write a program to print count of empty strings in java 8? |
|
Answer» The code to print the COUNT of empty strings in Java 8 is:- List strings = Arrays.asList("abc", "", "bc", "EFG", "abcd","", "jkl"); POINT to be NOTED: Go through this Q&A very thoroughly as this is ONE of the most asked java 8 interview questions. Example List<String>strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl"); int count = strings.stream().filter(string −> string.isEmpty()).count(); |
|
| 476. |
Write a program to print 15 random numbers using forEach of java 8? |
|
Answer» RANDOM random = NEW Random(); |
|
| 477. |
What are the difference between map and flatMap stream operation in Java 8? |
||||||
Answer»
Stream Pipelining is done by dividing the operations which can happen on the flow into two categories. The first is Intermediate operations and the SECOND is TERMINAL operations. The common operations return the stream itself so that the result can be pipelined. The terminal operations remain at the END of the pipelining operation. It returns the final value, and the pipeline is terminated. |
|||||||
| 478. |
What is Stream API in Java8? |
|
Answer» The Stream API is USED to process a group of objects. A stream is a series of objects which supports different methods that can be pipelined to produce the expected result. The features of the stream are –
|
|
| 479. |
What do you mean by JJS in Java8? |
|
Answer» JAVA 8 INTRODUCED a COMMAND TOOL jjs for the Nashorn to execute the javascript program codes at the console. |
|
| 480. |
What is Spliterator in Java 8? |
|
Answer» A Spliterator is a TYPE of Java8 Iterator in JAVA. util package that traverses and partitions the elements of a SOURCE in Java into ANOTHER Spliterator. A source can be a collection or an IO channel or a GENERATOR function |
|
| 481. |
What is the difference between collection and stream? |
||||||||||||
Answer»
|
|||||||||||||
| 482. |
Define Nashorn in Java8. |
|
Answer» Along with JAVA 8, a new improved engine Nashorn was INTRODUCED. Nashorn gives very high performance because it STRAIGHTAWAY compiles the program code in the memory and then passes the bytecode to JVM. It uses the invoke DYNAMICS feature of Java 7 to improve the performance. |
|
| 483. |
What is the syntax and characteristics of a Lambda Expression in JAVA 8? |
|
Answer» The syntax for the Lambda expression is:- parameter -> expression body Characteristics of the Lambda Expression:-
|
|
| 484. |
What is the use of default method in interface? |
|
Answer» The DEFAULT method implementation was introduced by Java 8 so that the OLD interfaces can use the lambda expression without implementing the methods in the implementation class. ExampleSYNTAX:- public INTERFACE interview { default void print() { System.out.println("Welcome Bestinterviewquestion.com"); } } |
|
| 485. |
What is Optional in Java 8? |
|
Answer» In java there a NullPointerException which can crash the code. It is complicated to remove the null checks from the code. Java 8 INTRODUCED Optional class in java. util PACKAGE. Use of Optional class results in clean code WITHOUT null checks. By USING the Optional class, the programmer can specify the other value or other code to return. This MAKES the code more readable. |
|
| 486. |
What do you mean by of String::valueOf expression in Java 8? |
|
Answer» The VALUEOF() method converts data into human-readable form.So String valueOf() will return the string representation of the value. The valueOf() method is a static method. |
|
| 487. |
What is method reference in Java 8? |
|
Answer» Method REFERENCES support in POINTING to the METHODS by their names. A method reference is denoted by USING "::" symbol. A method reference is used to indicate the following methods
This is a fundamental QUESTION in java 8 interview questions. |
|
| 488. |
What is a Java Lambda Expression? |
|
Answer» Lamba expression is considered as the most significant feature of JAVA8. A Lambda expression PROVIDES functional programming, and that has simplified the CODE to a great extent. A lambda expression is fundamentally a function which can be created WITHOUT BELONGING to any class. |
|
| 489. |
What are the new features in Java 8? |
|
Answer» New FEATURES introduced in Java 8 are:-
|
|
| 490. |
What is the purpose of functional interface in Java 8? |
|
Answer» FUNCTIONAL interfaces are those interfaces that have a SINGLE functionality. Example |
|
| 491. |
What is the difference between intermediate and terminal operations? |
||||||||||||
Answer»
|
|||||||||||||
| 492. |
What is the purpose of the System class in Java? |
|
Answer» System class has useful fields, such as static MEMBERS, that are related to the environment. This class is PROVIDED with STANDARD STREAMS like input, output and error. These streams can be used to access the properties and environment variables that are externally defined. |
|
| 493. |
Explain the difference between throw and throws in Java? |
||||||||||||
Answer»
|
|||||||||||||
| 494. |
What is Exception Handling in Java? |
|
Answer» Exception HANDLING allows developers to handle runtime ERRORS CAUSED by exceptions. One way to handle exceptions is to print a simple message for users that help them CORRECT the error that occurs due to bad data sent by the user. Exception handling ensures the flow of the application does not BREAK. |
|
| 495. |
How we can create packages in Java? |
|
Answer» Here are the steps for creating a package:
|
|
| 496. |
How we can make a read-only class in Java? |
|
Answer» By Read-only CLASS we are referring to the "IMMUTABLE" CONCEPT. You can begin by defining a class so that no methods can CAUSE changes to the internal state. In such classes, aliasing will have no impact because its internal state is read-only. 45. How we can make a write-only class in JAVA? |
|
| 497. |
What is instanceOf operator used in Java? |
|
Answer» INSTANCEOF operator is used in OBJECT REFERENCE variables. In this, the operator will check the class type or INTERFACE type of an object. It is WRITTEN as follows: ( Object reference variable ) instanceof (class/interface type) |
|
| 498. |
What is finalize() function in Java? |
|
Answer» This is a good question concerning core java INTERVIEW QUESTIONS for experienced professionals. FINALIZE method is CALLED by the Garbage Collector before performing the clean-up activity. Clean-up activity refers to the process of de-allocating all the resources, such as database connection and NETWORK connection, associated with an object. |
|
| 499. |
Define an applet in Java? |
|
Answer» APPLET is a Java program that gets embedded into web PAGES using the APPLET or OBJECT tag and runs inside the browser. It works at the client side, and is hosted on a web server. Applets MAKE WEBSITES dynamic and ENTERTAINING. |
|
| 500. |
What is JIT compiler in Java? |
|
Answer» JIT COMPILER is a COMPONENT of JRE that improves the performance of applications. JIT compiler improve the performance of JVM by compiling bytecode into MACHINE code at runtime. Choosing the right compiler is ONE of the first and biggest decisions to be made when you are running a Java application. |
|