0% found this document useful (0 votes)
9 views1 page

Java Basics: OOP, Strings, and Features

Uploaded by

jish376
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)
9 views1 page

Java Basics: OOP, Strings, and Features

Uploaded by

jish376
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

Basics

Q: What is Java?
A: Java is an object-oriented, platform-independent programming language. It works on the concept
'write once, run anywhere' because of JVM.
Q: Main features of Java?
A: Object-oriented, platform-independent, secure, robust, multithreaded, and portable.
Q: What is bytecode?
A: It’s the intermediate code generated by Java compiler, and JVM executes it.
Q: Difference between JVM, JRE, and JDK?
A: JVM runs bytecode, JRE is JVM plus libraries to run programs, JDK is JRE plus tools to develop
programs.
Q: Why is Java platform independent?
A: Because the code is converted into bytecode, and JVM executes the bytecode in any OS.

OOP
Q: What are OOP principles?
A: Encapsulation, Inheritance, Polymorphism, and Abstraction.
Q: What is Encapsulation?
A: Wrapping variables and methods into a single unit, like a class.
Q: What is Inheritance?
A: One class can acquire properties of another class using extends.
Q: What is Polymorphism?
A: Performing the same task in different ways. Overloading and Overriding.
Q: What is Abstraction?
A: Hiding the details and showing only the functionality. Done using abstract class and interface.

Strings
Q: Why is String immutable?
A: For security, caching, and thread safety.
Q: Difference between String, StringBuilder, StringBuffer?
A: String is immutable, StringBuilder is mutable and faster but not thread-safe, StringBuffer is
mutable and thread-safe.
Q: == vs equals()?
A: == checks reference, equals() checks content.
Q: What is String pool?
A: A special memory where string literals are stored and reused.
Q: concat vs + operator?
A: Both used, but + internally uses StringBuilder.

You might also like