Share E-Book

Java Interview Notes 700 Java Interview Questions Answered (M Jolly.) (z-library.sk, 1lib.sk, z-lib.sk)

Author

Rating 3.5 AI initial rating

Log in to rate

Java
Language English

Amazon Digital Services LLC, 2016. — 224 p. — ASIN: B01B0TCZ70Java Interview Notes incorporate most critical topics discussed during Java technical interview round, along with the interview questions for each concept. This book also contains lots of code snippets and figures to explain matters. Concepts in the book are organized in very precise and concise manner, in small chapters and are to the point. CONTENT: Java Fundamentals: Java Program Anatomy Java Program and JVM Data Types Naming Convention Object class Access Modifiers static final static initialization block finally finalize Widening vs Narrowing Conversion getters and setters varargs vs object array default interface method static interface method Annotations Preferences Pass by value or reference Object Oriented Programming: Polymorphism Parametric Polymorphism Subtype Polymorphism Overriding Override Overloading Abstraction Inheritance Composition Fundamental Design Concepts: DI vs IoC Service Locator Diamond Problem Programming to Interface Abstract class vs Interface Internationalization and Localization Immutable Objects Cloning Data Types : NaN EnumSet Comparing Data Types Float comparison String comparison Enum comparison enum vs public static int field Wrapper Classes Auto boxing and Auto unboxing BigInteger and BigDecimal Strings : String Immutability String Literal vs Object String Interning String Pool Memory Management Immutability - Security issue Circumvent String immutability StringBuffer vs StringBuilder Unicode Inner Classes: Inner Classes Static Member Nested Class Local Inner Class Non-Static Nested Class Anonymous Inner Class Functional Programming: Lambda Expression Functional Interface Pure Functions Fluent Interface Generics : Generics Generics-Type Wildcards Generics - Method Java Generics vs Java Array Generics - Type Erasure Co-variance Contra-variance Co-variance vs Contra-variance Collections : Collection design aspects Collection Fundamentals Collection Interfaces Collection

Format PDF
Size 1.6 MB
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
Java Interview Notes by Jolly Copyright © 2016 by Jolly M. All rights reserved, including the right to reproduce this book, or any portions of it, in any form.
Page 3
CONTENT Introduction Book Introduction Java Fundamentals Java Program Anatomy Java Program and JVM Data Types Naming Convention Object class static final static initialization block finally() finalize() Widening vs Narrowing Conversion getters and setters varargs vs object array default interface method static interface method Annotations Preferences Pass by value or reference Access Modifiers Object Oriented Programming Polymorphism Parametric Polymorphism Subtype Polymorphism Overriding
Page 4
@Override Overloading Abstraction Inheritance Composition Fundamental Design Concepts DI vs IoC Service Locator Diamond Problem Programming to Interface Abstract class vs Interface Internationalization and Localization Immutable Objects Cloning Data Types NaN EnumSet Comparing Data Types Float comparison String comparison Enum comparison enum vs public static int field Wrapper Classes Auto boxing and Auto unboxing BigInteger and BigDecimal Strings String Immutability String Literal vs Object String Interning
Page 5
String Pool Memory Management Immutability - Security issue Circumvent String immutability StringBuffer vs StringBuilder Unicode Inner Classes Inner Classes Static Member Nested Class Local Inner Class Non-Static Nested Class Anonymous Inner Class Functional Programming Lambda Expression Functional Interface Pure Functions Fluent Interface Generics Generics Generics-Type Wildcards Generics - Method Java Generics vs Java Array Generics - Type Erasure Co-variance Contra-variance Co-variance vs Contra-variance Collections Collection design aspects
Page 6
Collection Fundamentals Collection Interfaces Collection Types Set List Queue Map Algorithms Comparable vs Comparator hashCode() and equals() HashTable vs HashMap Synchronized vs Concurrent Collections Iterating over collections fail-fast vs fail-safe Error and Exception Exception Checked vs Unchecked vs Error Exception Handling Best Practices try-with-resource Threading Threading Terms Thread Lifecycle Thread Termination Runnable vs Thread Runnable vs Callable Daemon Thread Race Condition and Immutable object Thread Pool Synchronization
Page 7
Concurrent vs Parallel vs Asynchronous Thread Synchronization Synchronized method vs Synchronized block Conditional Synchronization Volatile static vs volatile vs synchronized ThreadLocal Storage wait() vs sleep() Joining Thread Atomic Classes Lock ReadWriteLock Synchronizers Barrier Semaphore Phaser Exchanger Latch Executor Framework Executor Service Fork-Join Framework Reflection Purpose of reflection Drawbacks of Reflection Data Interchange JSON Memory Management Stack vs Heap Heap fragmentation
Page 8
Object Serialization Garbage Collection Memory Management Weak vs Soft vs Phantom Reference Unit Testing Why unit testing? Unit vs Integration vs Regression vs Validation Testing private members Mocking and Mock Objects Java Tools Git Maven Ant Jenkins
Page 9
INTRODUCTION
Page 10
Introduction Java Interview Notes cover topics that are frequently discussed during Java technical interview round, along with interview questions for each topic. This book also contains lots of code snippets and figures to explain topics. To be confident in an interview, thorough understanding of software design and language concepts is very important, because during an interview same question can be asked in many different ways. Interviewers are interested in hearing not just the correct answer, but also your opinion and thoughts about the topic. Your approach towards understanding the questions and sharing your thoughts plays an extremely important role in an interview success. Confidence to face such interview can only be achieved when you spend really good amount of time coding, reading technical topics and discussing this with peers. There is no other shortcut available. I hope this book helps to prepare you not only for your next interview, but also for your day-to-day software development task. All the best!!!
Page 11
JAVA FUNDAMENTALS
Page 12
Java Program Anatomy The following code snippet depicts the anatomy of simple Java program.
Page 13
(This page has no text content)
Page 14
Package - Represents logical grouping of similar types into namespaces. It also prevents naming collision and provides access protection. Import - Imports the package, so that classes can be used in the code by their unqualified names. Class - Represents a type template having properties and methods. Field - Represents a member used for holding values. Method - Represents an operation/behaviour of the class. Modifier - Specifies access control level of a class and its members. Parameter - Specifies the variable declared in the method definition. Argument - Specifies the data passed to the method parameters. Questions What is package? Why do you need to import packages? Why do you need to specify access modifiers? What is static import? static import enables access to static members of a class without need to qualify it by the class name. What is the difference between argument and parameter?
Page 15
Compiling and Executing Java Code in JVM Java program compilation and execution steps
Page 16
(This page has no text content)
Page 17
1. Java Compiler compiles the Java source code (.java file) into a binary format known as bytecode (.class file). Java bytecode is platform independent instruction set, which contains instructions (opcode) and parameter information. 2. Bytecode is translated by the Operating System specific Java Virtual Machine (JVM) into the platform specific machine code. 3. Class loader in JVM loads the binary representation of the classes into memory. 4. Execution engine in JVM executes the byte code and generates Operating System specific machine instructions. These machine instructions are executed directly by the central processing unit (CPU). Questions Explain the process of Java code compilation and execution? What is bytecode? What is the difference between bytecode and source code? What is machine code? What is the difference between bytecode and machine code? What is JVM? Is it same or different for different Operating Systems? What are the major components of JVM? What is the role of class loader in JVM? What is the role of Execution Engine in JVM? What are machine instructions?
Page 18
Data Types Primitive Types Primitive types are byte, boolean, char, short, int, float, long and double. Primitive types always have a value; if not assigned, will have a default value. A long value is suffixed with L (or l) to differentiate it from int. A float value is suffixed with F (or f) to differentiate it from double. Similarly double is suffixed with D (or d) A char is unsigned and represent an Unicode values. When a primitive type is assigned to another variable, a copy is created. Reference Types All non-primitive types are reference types. Reference types are also usually known as objects. A reference type also refers to an object in memory. Objects of reference type will have null as default value, when it’s unassigned. Objects have variables and methods, which define its state and the behaviour. When a reference is assigned to another reference, both points to the same object. Questions What are primitive data types? If a variable of primitive data type is not assigned, what does it contain? Why do we suffix L with long, F with Float and D with double? What happens when you assign a variable of primitive data type to another variable of same type? What are reference data types? What happens when you assign a variable of reference data type to another variable of same reference type? What are the differences between primitive data types and reference data types? What are the purposes of variables and methods in a reference type? If a variable of reference data type is not assigned, what does it contain?
Page 19
Object class Every Java class is inherited, directly or indirectly, from java.lang.Object class, which also means that a variable of Object class can reference object of any class. Due to inheritance, all the following java.lang.Object class methods, which are not final or private, are available for overriding with class specific code. hashCode() - returns hash-code value for the object. equals() - compares two objects for equality using identity (==) operator. clone() - creates copy of object. Overriding class should inherit Cloneable interface and implement clone() method to define the meaning of copy. toString() - returns string representation of the object. finalize() - called by the Garbage Collector to clean up the resources. java.lang.Object’s implementation of finalize() does nothing. Questions What is the base class for all Java classes? What are the different methods of java.lang.Object class, which are available for overriding in the derived class. What happens if your class does not override equals method from the java.lang.Object class? The equals() method in java.lang.Object class compares whether object references are same, and not the content. To compare content, you need to override equals() method. What is the purpose of clone() method? Why should the overriding class define the meaning of clone() method? What happens if overriding class does not override clone() method? In case if an object contains references to an external objects, any change made to the referenced object will be visible in the cloned object too.
Page 20
Access Modifiers Access modifiers determine the visibility rules whether other classes can access a variable or invoke a method. At class level, you can either use public modifier or no modifier. For class members, you can use one of the following access modifiers. private - External classes cannot access the member. protected - Only sub-classes can access the member. public - All classes in the application can access the member. no modifier - All classes within the package can access this member. The access modifier in the overriding methods should be same or less restrictive than the overridden method. Optional static and final keywords are frequently used along with the access modifiers. Questions What is the purpose of access modifier? Is there any difference between the list of access modifiers available for a class and for its members? What is the scope of private, protected and pubic access modifiers? What happens when no access modifier is specified with the class? If sub-class exists in a different package, does it still has visibility to the protected members of the super-class? Why should the member access modifier in the derived class be less restrictive than the base? As per inheritance concept, you should be able to use sub class object with super class reference. This will not be possible if sub class member is declared with more restrictive access modifier. What should be the criteria to decide an access modifier for a class? You should use the most restrictive access modifier to ensure security and to prevent any misuse.
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List