0% found this document useful (0 votes)
72 views4 pages

Java 8 Features and Core Concepts Guide

The document outlines key concepts and features of Java, including important features introduced in Java 8 such as Lambda Expressions and Streams API. It explains Java's platform independence, the differences between JDK, JVM, and JRE, and various object-oriented principles like inheritance and polymorphism. Additionally, it covers exception handling, Java collections, memory management, and control flow statements.

Uploaded by

d7frpg49wb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views4 pages

Java 8 Features and Core Concepts Guide

The document outlines key concepts and features of Java, including important features introduced in Java 8 such as Lambda Expressions and Streams API. It explains Java's platform independence, the differences between JDK, JVM, and JRE, and various object-oriented principles like inheritance and polymorphism. Additionally, it covers exception handling, Java collections, memory management, and control flow statements.

Uploaded by

d7frpg49wb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java 8 and General Java Concepts

1. What are the important features of Java 8 release?


• Lambda Expressions
• Streams API
• Functional Interfaces
• Default & Static Methods in Interfaces
• New Date and Time API
• Optional Class

2. What do you mean by platform independence of Java?


• Java code is compiled into bytecode, which runs on any system with a JVM.

3. What is JVM and is it platform independent?


• JVM (Java Virtual Machine) is an abstract machine that executes Java bytecode. JVM itself is
platform-dependent, but Java bytecode is platform-independent.

4. What is the difference between JDK and JVM?


• JDK (Java Development Kit): Includes JRE + compilers + development tools.
• JVM (Java Virtual Machine): Executes bytecode, part of JRE.

5. What is the difference between JVM and JRE?


• JVM: Runs Java programs.
• JRE (Java Runtime Environment): Includes JVM + standard libraries.

Java Object-Oriented Concepts


6. Which class is the superclass of all classes?
• [Link]

7. Why Java doesn’t support multiple inheritance?


• To avoid ambiguity and maintain simplicity. Java supports multiple inheritance via interfaces.

8. Why Java is not a pure Object-Oriented language?


• Java includes primitive data types (int, char, etc.), making it not 100% object-oriented.

9. What is the difference between path and classpath variables?


• Path: Used for locating executables (javac, java).
• Classpath: Used for locating Java class files.

Java Methods and Overloading


10. What is the importance of the main method in Java?
• It is the entry point of a Java program: public static void main(String[] args)

11. What is overloading and overriding in Java?


• Overloading: Same method name, different parameters (compile-time polymorphism).
• Overriding: Redefining superclass methods in a subclass (runtime polymorphism).

12. Can we overload the main method?


• Yes, but the JVM calls only public static void main(String[] args).

13. Can we have multiple public classes in a Java source file?


• No, only one public class per .java file.

Java Packages and Modifiers


14. What is a Java Package and which package is imported by default?
• A package is a namespace that groups related classes.
• [Link] is imported by default.

15. What are access modifiers?


• private, default, protected, public

16. What is the final keyword?


• Used to define constants, prevent method overriding, and prevent inheritance.

17. What is the static keyword?


• Used for variables, methods, blocks, and inner classes that belong to the class rather than instances.

Exception Handling in Java


18. What is finally and finalize in Java?
• finally: Executes after try-catch block.
• finalize(): Called by the garbage collector.

19. Can we declare a class as static?


• Only inner classes can be static.

20. What is static import?


• Allows importing static members (import static [Link]).

21. What is try-with-resources in Java?


• Ensures automatic resource management in try blocks.

22. What is a multi-catch block in Java?


• Allows catching multiple exceptions in a single catch block.

Java OOP: Abstract Classes & Interfaces


23. What is an interface?
• A collection of abstract methods that a class must implement.

24. What is an abstract class?


• A class that can have both abstract and concrete methods.

25. What is the difference between an abstract class and an interface?


• Abstract class can have both abstract and concrete methods.
• Interfaces (before Java 8) had only abstract methods.

26. Can an interface implement or extend another interface?


• Yes, interfaces can extend other interfaces.

27. What is a Marker interface?


• An interface with no methods (e.g., Serializable).

Java Collections & Memory Management


28. What are Wrapper classes?
• Convert primitives to objects (Integer, Double, etc.).

29. What is an Enum in Java?


• A special class to define constants.

30. What is Java Annotations?


• Metadata used for code processing (@Override, @Deprecated).
31. What is Composition in Java?
• A design principle where objects contain other objects.

32. What is the benefit of Composition over Inheritance?


• Avoids tight coupling.

33. What is Garbage Collection?


• Automatic memory management in Java.

Java Memory and Execution


34. Java is Pass by Value or Pass by Reference?
• Always pass by value.

35. What is the difference between Heap and Stack Memory?


• Heap: Stores objects.
• Stack: Stores local variables and method calls.

36. Where is the Java Compiler stored?


• In JDK, under bin/[Link].

Miscellaneous Java Questions


37. How to run a JAR file through the command prompt?
• java -jar [Link]

38. What is the use of the System class?


• Provides utility methods ([Link](), [Link]()).

39. What is the instance of keyword?


• Checks object type (obj instance of Class Name).

40. Can we use String with a switch case?


• Yes, from Java 7 onwards.

Control Flow Statements in Java


41. What is the ternary operator in Java?
• condition ? true Value : false Value

42. What does the super keyword do?


• Refers to the superclass.

43. What is the difference between break and continue statements?


• break: Exits loop.
• continue: Skips iteration.

44. What is the this keyword?


• Refers to the current object.

45. What is a default constructor?


• A constructor with no parameters.

46. Can we have try without a catch block?


• Yes, if finally is present.

47. What is Serialization and Deserialization?


• Serialization: Converts objects to byte streams.
• Deserialization: Converts byte streams back to objects.

You might also like