🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: What is the transient keyword in Java? The transient keyword is used to exclude a variable from serialization when we don’t want its value to be saved in a file or transferred over the network. 🔹 Used only with instance variables 🔹 Prevents sensitive or unnecessary data from being serialized 🔹 JVM ignores the original value during serialization 🔹 After deserialization, the variable gets its default value 🔹 Commonly used for passwords, security keys, temporary data 💡 transient helps control what data should and should not be persisted during object serialization. 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” to get Core Java, Advanced Java & real-time interview prep 👉For Java Course Details Visit:https://lnkd.in/gwBnvJPR . #Java #CoreJava #TransientKeyword #JavaSerialization #JavaInterviewQuestions #JavaDeveloper #CodingInterview #AshokIT #AshokITSchool
Java transient keyword: serialization control
More Relevant Posts
-
🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: Why can’t we create a generic array in Java? Generic arrays cannot be created in Java because of Type Erasure. 🔹 Arrays are reified – they retain their type information at runtime 🔹 Generics are implemented using Type Erasure – type information is removed at compile time 🔹 Arrays perform a runtime type check and can throw ArrayStoreException 🔹 If generic arrays were allowed, the runtime type safety of arrays would break 💡 Since arrays check types at runtime and generics lose type information after compilation, combining both would cause type safety issues. That’s why Java does not allow: new T[] new List<String>[] 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” to get Core Java, Collections & Advanced interview prep 👉For Java Course Details Visit:https://lnkd.in/gwBnvJPR . #Java #CoreJava #Generics #TypeErasure #JavaInterviewQuestions #JavaCollections #Programming #AshokIT #AshokITSchool
To view or add a comment, sign in
-
-
🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: What is Exception Propagation? Exception propagation is the process where an exception moves up the call stack until it is handled. When an exception occurs inside a method: 1️⃣ If it is not caught in the same method, 2️⃣ It is passed to the calling method, 3️⃣ This continues up the stack until the exception is caught, 4️⃣ If no method handles it, the program terminates and the JVM prints the stack trace. 👉 Here, the exception occurs in method1(), 👉 It propagates to method2(), 👉 Then to method3() where it is finally handled. 💡 Interview Tip: Exception propagation mainly applies to Unchecked Exceptions (Runtime Exceptions). Checked exceptions must be handled or declared using throws. 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” for more concepts 👉For JavaCourse Details Visit : https://lnkd.in/gwBnvJPR . #Java #JavaInterviewQuestions #CoreJava #ExceptionHandling #ExceptionPropagation #Programming #CodingInterview #AshokIT
To view or add a comment, sign in
-
-
🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: Why does the Java array index start with 0? In Java, the array index represents the offset (distance) from the base memory address of the array. 🔹 The first element is stored at the base address 🔹 Its distance from the base address is 0 🔹 Therefore, the first index is 0 📌 Memory Calculation Formula: Address = Base_Address + (index × size_of_element) When index = 0 → Address = Base_Address + (0 × size) = Base_Address So, the first element is located exactly at the base address. 💡 Zero-based indexing makes memory access efficient and simplifies pointer arithmetic (in low-level implementation). 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” to get Core Java & Advanced interview prep 👉For Java Course Details Visit:https://lnkd.in/gwBnvJPR . #Java #CoreJava #JavaInterviewQuestions #Arrays #ProgrammingConcepts #JavaDeveloper #CodingInterview #AshokIT #AshokITSchool
To view or add a comment, sign in
-
-
🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: What are the different ways to create objects in Java? There are 5 main ways to create objects in Java: 🔹 1. Using the new Keyword The most common method. Student s = new Student(); 🔹 2. Using Class.forName().newInstance() Creates an object using reflection. 🔹 3. Using clone() Method Creates a copy of an existing object. 🔹 4. Using Deserialization An object is created when we deserialize a serialized object. 🔹 5. Using Constructor.newInstance() Creates an object using the Constructor class (Reflection API). 💡 The new keyword is the most frequently used approach in real-time applications. 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” for Core & Advanced Java concepts 👉For Java Course Details Visit:https://lnkd.in/gwBnvJPR . #Java #CoreJava #JavaInterviewQuestions #OOPS #JavaDeveloper #Programming #CodingInterview #AshokIT #AshokITSchool
To view or add a comment, sign in
-
-
🚀 Java Core Concepts – Interview Question 📌 Question: On which memory are arrays created in Java? 🔹 Answer: In Java, arrays are always created in Heap memory, regardless of where they are declared. ✔ Inside a method (local variable) ✔ As an instance variable ✔ As a static variable 👉 The array object itself is stored in the Heap. 🔹 Important Concept: Even if the array reference is: 🔹 Local variable → Reference stored in Stack, array object in Heap 🔹 Instance variable → Reference stored in Heap (inside object) 🔹 Static variable → Reference stored in Method Area, array object in Heap But the actual array elements are always stored in Heap memory. 💡 Interview Tip: ✔ Arrays are objects in Java ✔ All objects are created in Heap ✔ Only references may differ in memory location 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” for more concepts 👉For Java Course Details Visit : https://lnkd.in/gwBnvJPR . #Java #CoreJava #JavaMemory #HeapMemory #StackMemory #JavaInterviewQuestions #Programming #AshokIT
To view or add a comment, sign in
-
-
🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: What are the advantages and disadvantages of object cloning in Java? Object cloning in Java is done using the clone() method to create a copy of an existing object. ✅ Advantages of Object Cloning 🔹 Creates a new object without using the new keyword 🔹 Reduces boilerplate code (no need for manual field copying) 🔹 Useful for copying complex objects 🔹 Supports Prototype Design Pattern 🔹 Faster than creating objects manually in some cases ❌ Disadvantages of Object Cloning 🔹 clone() method is protected in Object class 🔹 Class must implement Cloneable interface 🔹 By default, performs shallow copy (not deep copy) 🔹 Deep copy requires extra implementation 🔹 Can be difficult to manage with nested or mutable objects 💡 In real-time projects, many developers prefer copy constructors or factory methods instead of cloning. 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” for more Core & Advanced concepts 👉For Java Course Details Visit:https://lnkd.in/gwBnvJPR . #Java #CoreJava #ObjectCloning #OOPS #JavaInterviewQuestions #PrototypePattern #Programming #CodingInterview #AshokIT #AshokITSchool
To view or add a comment, sign in
-
-
🚗 Java Execution Flow explained with Real-World Analogies ☕🔥 Many beginners write Java code, but interviews test whether you understand what really happens inside the JVM. This infographic visually explains the complete Java lifecycle using real-world examples to make concepts stick. 📌 Covered in this post: ✅ Compile & Run flow (javac → .class → java ClassName) ✅ File name vs public class rule (real Java rule, no myths) ✅ Multiple classes & multiple main() in one file ✅ JVM Memory: Method/Meta area, Heap, Stack ✅ Class Loader – when and how classes are loaded ✅ 7 elements of a Java class (static vs instance) ✅ Static vs Instance access rules (very important ⚠️) ✅ Real execution order (static → main → object creation) ✅ 30-second interview-ready explanation 🎯 If you are: Learning Core Java Preparing for Java interviews Teaching or mentoring beginners 👉 Save this post — it’s designed for quick revision before interviews. 💬 Comment “Java” if you want more concept-to-visual posts 🔁 Share with someone who’s struggling with JVM internals #Java #CoreJava #JVM #JavaInterview #ProgrammingBasics #OOP #ClassLoader #ExecutionFlow #LearningWithExamples
To view or add a comment, sign in
-
-
🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: On which memory are arrays created in Java? In Java, arrays are always created in Heap memory, regardless of where they are declared. Whether: 🔹 Declared inside a method (local variable) 🔹 Declared as an instance variable 🔹 Declared as a static variable The array object is stored in the Heap. 🎯 Key Point: ✔ Only the reference variable may be stored in Stack (if local). ✔ The actual array elements are always stored in Heap memory. ✔ Heap memory is managed by the Garbage Collector (GC). 💡 Interview Tip: In Java, arrays are objects — and all objects are created in the Heap. 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” for more core concepts 👉For Java Course Details Visit : https://lnkd.in/gwBnvJPR . #Java #CoreJava #JavaInterviewQuestions #HeapMemory #JVM #Programming #CodingInterview #AshokIT
To view or add a comment, sign in
-
-
🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: What do you understand by a jagged array in Java? A Jagged Array (also called a Ragged Array) is an array of arrays where each inner array can have a different length. Unlike a regular 2D array (matrix), rows in a jagged array are not required to have the same number of columns. 📌 Example: int[][] arr = { {1, 2, 8}, {7, 5}, {6, 7, 2, 6} }; Here: First row → 3 elements Second row → 2 elements Third row → 4 elements Each row has a different size. 🎯 Key Points: 🔹 It is a two-dimensional array with varying column sizes 🔹 Memory is allocated separately for each row 🔹 Useful when data is not uniform (e.g., triangular matrix) 💡 In interviews, remember: Java does not truly support multidimensional arrays — it supports arrays of arrays. 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” for more core concepts 👉For Java Course Details Visit : https://lnkd.in/gwBnvJPR . #Java #CoreJava #JaggedArray #2DArray #JavaInterviewQuestions #OOPS #Programming #CodingInterview #AshokIT
To view or add a comment, sign in
-
-
🚀 Java Core Concepts – Interview Questions & Answers 📌 Question: What is the purpose of a default constructor? A constructor is a special method used to initialize objects when they are created. A default constructor: ✔ Does not take any parameters ✔ Is automatically provided by the compiler if no constructor is defined ✔ Initializes instance variables with default values 🔹 What does it do? 👉 The compiler provides a default constructor. 👉 Instance variables get default values (0, null, false, etc.). 🔹 Important Points: ✔ If you define any constructor, the compiler will NOT create a default constructor automatically. ✔ A default constructor can also be explicitly written. ✔ It is mainly used for object initialization with default state. 💡 Interview Tip: Default constructor ≠ No-argument constructor (though both look similar). A no-arg constructor is explicitly written by the programmer. 👉 Follow Ashok IT School for daily Java interview questions 👉 Comment “JAVA” for more concepts 👉For Java Course Details Visit : https://lnkd.in/gwBnvJPR . #Java #CoreJava #JavaInterviewQuestions #OOPS #Constructors #Programming #CodingInterview #AshokIT
To view or add a comment, sign in
-
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development