· 5 years ago · Mar 12, 2020, 04:14 PM
1
2
3Java:
4-------------------
5Q1: Difference between Final, Finally and Finalize
6A: (Final is a keyword) (Finally is a block or can be used a keyword) (Finalize is a method)
7Final keyword is used as a modifier used for variables, classes and methods. Once declared using final they cannot be changed or inherited or overwritten respectively.
8Finally block is used with try or try catch blocks to perform cleanup activities.
9Finalize method is invoked by the garbage collector to perform clean up activities before destroying the object. Finalize method can be overridden.
10Source: https://www.youtube.com/watch?v=Dxpdo9BUGss&t=4s || https://youtu.be/RLInHtq9j2w
11
12Q2: Difference between String and StringBuffer
13A: String objects are immutable while StringBuffer objects are mutable(liable to change).
14In case on String, once an object is created then it cannot be changed but we can change the reference to the object.
15While in case of StringBuffer, the object can be changed.
16Source: https://www.youtube.com/watch?v=zwocnEB9_1I
17
18Q3: Difference between exception and error
19A: Throwable acts as exception of Java exception hierarchy. It contains two child classes, exception and error.
20Exceptions: they are caused by our code and are recoverable. (recover by try and catch blocks)
21Errors: these are caused due to lack of system resources and are non-recoverable.
22
23Q4: Difference between interface and abstract class.
24A: Abstract class: Abstraction is a process of hiding the implementation details and showing only functionality to the user. Another way, it shows only essential things to the user and hides the internal details, for example, sending SMS where you type the text and send the message. You don't know the internal processing about the message delivery.
25There are two ways to achieve abstraction in java:
26Abstract class (0 to 100%)
27Interface (100%)
28A class which is declared as abstract is known as an abstract class. It can have abstract and non-abstract methods. It needs to be extended and its method implemented. It cannot be instantiated. It can have constructors.
29We can have an abstract class without any abstract method. This allows us to create classes that cannot be instantiated, but can only be inherited.
30Source: https://www.javatpoint.com/abstract-class-in-java
31Interface: An interface is a completely abstract class that contains only abstract methods(it's a collection of abstract methods). An interface is implicitly abstract. You do not need to use the abstract keyword while declaring an interface. Methods in an interface are implicitly public.
32Use the implements keyword to use an interface with your class.
33All of the abstract methods declared in an Interface should be implemented by the subclass with same return type and same access level or the program won't execute.
34Declaration:
35interface MyInterface
36{
37 // All the methods are public abstract by default
38 // As you see they have no body
39 public void method1();
40 public void method2();
41}
42
43Q5: Overloading and Overriding
44A: Overloading: Two methods are said to be overloaded when both of them have the same name but different argument types.
45Eg:
46public void num(int n){ }
47public void num(double n){ }
48Overriding: Parent method has default properties available to the child but sometimes child may not be satisfied with the parent method so the child is allowed to redefine the parent method based on its requirements. This process is called overriding.
49Eg: https://funkyimg.com/i/2XeTV.png
50Differences:
511: Method names must be same for both overriding and overloading.
522: Argument types must be different(at least by order) for overloading. But in case of overriding, argument types must be exactly the same(including order).
533: Method signatures must be same for overloading and different for overriding.
544: Return type - (no restrictions for overloading) (must be same for overriding).
55
56Q7: Difference between Abstraction and Encapsulation
57A: Source: https://i.stack.imgur.com/07dXi.png
581: (abstraction) used for hiding unwanted data and giving relevant data. (encapsulation) means hiding the code and the data into a single unit to protect the data from outside world.
592: (abstraction) solves the problem in designer level. (encapsulation) solves the problem in implementation level.
603: Eg: (abstraction) outer look of a mobile phone like display, keyboard. (encapsulation) inner implementation of details of a mobile phone, how keyboard and display are connected to each other.
61
62Q8: Big-O notation
63O(1) - Constant time - irrespective of the size of input. It takes same time for 1GB of data or 100 GB of data.
64O(N) - Linear time - time varies depending of the size of data. Where N is the number of elements in the Array or similar.
65O(N^2) - Quadratic time - Not linear. Parabolic
66
67Q9: Array List
68A: ArrayLists are created with an initial size, but when this size is exceeded, the collection is automatically enlarged. ArrayLists store objects.
69ArrayList colors = new ArrayList();
70You can optionally specify a capacity and type of objects the ArrayList will hold: ArrayList<String> colors = new ArrayList<String>(10);
71The ArrayList class provides a number of useful methods for manipulating its objects.
72- add() - adds new object. Eg: arayname.add("red")
73- remove() - removes the specified. Eg: arrayname.remove("red")
74- contains() - checks for the specified object in the array. Eg: arrayname.contains("red");
75- get(int index): Returns the element at the specified position in the list. Eg: arrayname.get(1);
76- size(): Returns the number of elements in the list. Eg: arrayname.size();
77- clear(): Removes all of the elements from the list. Eg: arrayname.clear();
78
79Q10: LinkedList
80A: Similar to arrays in Java, LinkedList is a linear data structure. However LinkedList elements are not stored in contiguous locations like arrays, they are linked with each other using pointers.
81Each element in the LinkedList is called the Node. Each Node of the LinkedList contains two items: 1) Content of the element 2) Pointer/Address/Reference to the Next Node in the LinkedList.
82The LinkedList is very similar in syntax to the ArrayList. You can easily change an ArrayList to a LinkedList by changing the object type.
83LinkedList<String> list = new LinkedList<String>();
84Image: https://beginnersbook.com/wp-content/uploads/2013/12/singly_linkedlist.png
85Methods in LinkedList:
86list .add(); - add element
87list .addLast(); - add element to the end
88list .addFirst(); - add element of the beginning
89list .clear() - deletes the LinkedList.
90list.isEmpty() - checks if the list is empty.
91list.peek() - this method returns the first element in the list without removing it.
92list.remove() - removes the element from head.
93list.remove(index) - removes the element from the specified index;
94
95Q11: Collections in Java
96A: Declaring hundreds of variables to store hundreds of values is a worst programming practice also,
97Arrays:
98(Advantages) - Can declare any number of variables
99(Disadvantages) - Once declared, the size of an array cannot be changed. Accepts only elements of same data types.
100To overcome these limitations, collections concept was introduced
101Collections:
102If we want to represent a group of individual objects as a singe entity then we should go for collection.
103Collections are growable in nature. Can hold both homogeneous and heterogeneous elements. By default collections are not TypeSafe.
104ArrayList
105LinkedList
106Vector
107HashSet
108LinkedHashSet
109TreeSet
110HashMap
111TreeMap
112LinkedHashMap
113Hashtable
114Iterator & ListIterator
115Comparable & Comparator interface
116Difference between Arrays and Collections: https://funkyimg.com/i/2Xtsn.png
117
118Q12: Data Structures
119A: Data structures means different ways of storing the data for easy manipulation and access.
120Primitive DS: Int, Float, Boolean, Char. Rest are all non-primitive DS.
121Physical DS: Arrays, LinkedList
122Logical DS: Trees, Hashing, Stack, Queue, Graphs
123Source: https://funkyimg.com/i/2Xtxm.png
124
125Q13: Recursion
126A: Recursion is nothing but a method calling itself over and over until the base condition is reached. Recursion is only used when we can breakdown the problem into similar sub problems.
127Eg:
128public int fact(int n){
129 if(n == 1 || n == 0) return 1; //base condition
130 else return n * fact(n-1); //method calling itself
131}
132The above method returns the factorial of the given number.
133Properties:
134Same operation is performed multiple times with different inputs.
135In every step the problem becomes smaller.
136We need a base condition, which tells the system to stop the recursion.
137
138Q14: Type Casting
139A: Assigning a value of one type to a variable of another type is known as Type Casting.
140Eg: int a = (int) 3.14; //output = 3
141
142Q15: Enum
143A: An Enum is a special type used to define collections of constants.
144Eg:
145enum Rank {
146 SOLDIER,
147 SERGEANT,
148 CAPTAIN
149}
150You can refer to the constants in the enum above with the dot syntax. Rank a = Rank.SOLDIER;
151
152Q16: HashMap
153A: HashMap is a part of Java’s collection since Java 1.2. It stores the data in (Key, Value) pairs. To access a value one must know its key.
154HashMap is known as HashMap because it uses a technique called Hashing. Hashing is a technique of converting a large String to small String that represents the same String. A shorter value helps in indexing and faster searches.
155Arrays and Lists store elements as ordered collections, with each element given an integer index while HashMap is used for storing data collections as key and value pairs. One object is used as a key (index) to another object (the value).
156The put, remove, and get methods are used to add, delete, and access values in the HashMap.
157HashMap<String, Integer> map = new HashMap<String, Integer>();
158map.put("Amy", 154);
159System.out.println(map.get("Amy")); // 154
160A HashMap cannot contain duplicate keys. Adding a new item with a key that already exists overwrites the old element.
161HashMap methods:
162map.put();
163map.get();
164map.containsKey();
165map.containsValue();
166map.isEmpty();
167map.size();
168map.clear();
169map.values();
170
171Q17: Set
172A: A Set is a collection that cannot contain duplicate elements. It models the mathematical set abstraction. One of the implementations of the Set is the HashSet class.
173HashSet<String> set = new HashSet<String>();
174 set.add("A");
175 set.add("B");
176 set.size(); // returns the size of HashSet = 2
177System.out.println(set); //[A, B]
178Examples of Sets: HashSet, TreeSet
179Methods in HashSet: The following methods take O(1)
180set.add();
181set.remove();
182set.contains();
183set.clear(); - clears all the elements in the set.
184
185Q18: Difference between HashSet and TreeSet
186A: HashSet is Implemented using a hash table. Elements are not ordered. The add, remove, and contains methods have constant time complexity O(1).
187TreeSet is implemented using a tree structure(red-black tree in algorithm book). The elements in a set are sorted, but the add, remove, and contains methods has time complexity O(log (n)). It offers several methods to deal with the ordered set like first(), last(), headSet(), tailSet(), etc.
1881) First major difference between HashSet and TreeSet is performance. HashSet is faster than TreeSet and should be preferred choice if sorting of element is not required.
1892) Second difference between HashSet and TreeSet is that HashSet allows null object but TreeSet doesn't allow null Object and throw NullPointerException, Why, because TreeSet uses compareTo() method to compare keys and compareTo() will throw java.lang.NullPointerException.
1903) Another significant difference between HashSet and TreeSet is that, HashSet is backed by HashMap while TreeSet is backed by TreeMap in Java.
1914) One more difference between HashSet and TreeSet which is worth remembering is that HashSet uses equals() method to compare two object in Set and for detecting duplicates while TreeSet uses compareTo() method for same purpose.
1925) Now most important difference between HashSet and TreeSet is ordering. HashSet doesn't guaranteed any order while TreeSet maintains objects in Sorted order defined by either Comparable or Comparator method in Java.
1936) TreeSet does not allow to insert Heterogeneous objects. It will throw classCastException at Runtime if trying to add hetrogeneous objects, whereas HashSet allows hetrogeneous objects.
194Source: https://stackoverflow.com/questions/25602382/java-hashset-vs-treeset-when-should-i-use-over-other/25602519
195
196Q19: Sorting Lists
197A: For the manipulation of data in different collection types, the Java API provides a Collections class, which is included in the java.util package.
198One of the most popular Collections class methods is sort(), which sorts the elements of your collection type. The methods in the Collections class are static, so you don't need a Collections object to call them.
199Let's say an ArrayList animals consists of different animals, then
200Collections.sort(animals);
201System.out.println(animals); // outputs in sorted order [cat, dog, snake, tiger]
202As you can see, the elements have been sorted alphabetically.
203Other useful methods in the Collections class:
204max(Collection c): Returns the maximum element in c as determined by natural ordering. Eg: Collections.max(list name);
205min(Collection c): Returns the minimum element in c as determined by natural ordering.
206reverse(List list): Reverses the sequence in list.
207shuffle(List list): Shuffles (i.e., randomizes) the elements in list.
208
209Q20: Iterator
210A: An Iterator is an object that enables to cycle through a collection, obtain or remove elements.
211The Iterator class provides the following methods:
212- hasNext(): Returns true if there is at least one more element; otherwise, it returns false.
213- next(): Returns the next object and advances the iterator.
214- remove(): Removes the last object that was returned by next from the collection.
215Eg:
216import java.util.Iterator;
217import java.util.LinkedList;
218public class MyClass {
219 public static void main(String[ ] args) {
220 LinkedList<String> animals = new LinkedList<String>();
221 animals.add("fox");
222 animals.add("cat");
223 animals.add("dog");
224 animals.add("rabbit");
225 Iterator<String> it = animals.iterator();
226 while(it.hasNext()) {
227 String value = it.next();
228 System.out.println(value);
229 }
230 }
231}
232/*
233fox
234cat
235dog
236rabbit
237*/
238
239Q21: Vector in Java
240A: Vector is very same as ArrayList. Vector is a dynamic array whose length is 10 initially. If we add more than 10 elements then the length becomes 20 then 40, etc. Vector is synchronized theoretically.
241Declaration & methods:
242Vector<Integer> v = new Vector();
243v.add(1);
244v.remove(1);
245v.capacity(); //displays the length of the vector.
246
247Q22: Difference between core Java and Advance Java
248A: Both of these are used for different purposes.
249(Core) is used to develop general purpose applications.
250(Advanced) is used for creating Online applications and mobile applications.
251(Core) without core Java no one can develop any advanced Java applications.
252(Advanced) advanced java only deals with some specialization like Database, DOM(web), networking etc.
253(Core) covers OOP, data types, operators, functions, loops, exception handling, threading etc.
254(Advanced) Apart from the core java parts it has some specific sections like database connectivity, web services, Servlets etc.
255(Core) It uses only one tier architecture that is why it is called as ‘stand alone’ application.
256(Advanced) It uses two tier architecture i.e. client side architecture and server side or backend architecture.
257(Core) covers the swings, socket, awt, thread concept, collection object and classes.
258(Advanced) Advance java is used for web based application and enterprise application.
259
260Q23: Wrapper Classes
261A: Wrapper classes convert the Java primitives into the reference types (objects). Every primitive data type has a class dedicated to it. These are known as wrapper classes because they “wrap” the primitive data type into an object of that class.
262The following represents primitive data types and their respective object types.
263(char - Character) (byte - Byte) (short - Short) (long - Integer) (float - Float) (double - Double) (boolean - Boolean)
264Autoboxing: Automatic conversion of primitive types to the object of their corresponding wrapper classes is known as autoboxing.
265For example – conversion of int to Integer, long to Long, double to Double etc.
266Unboxing: It is just the reverse process of autoboxing. Automatically converting an object of a wrapper class to its corresponding primitive type is known as unboxing.
267For example – conversion of Integer to int, Long to long, Double to double etc.
268
269Q24: ASCII Values
270A: [A - Z] = [65 - 90] ; [a - z] = [97 - 122]
271
272Q25: Primitive data types and their max values
273A: [Boolean = 1 bit]
274[byte = 1 byte]
275[char = 2 bytes]
276[short = 2 bytes]
277[int = 4 bytes]
278[long = 8 bytes]
279[float = 4 bytes]
280[double = 8 bytes]
2811 byte = 8 bits = 2^8
282Range of int = {-2^31 to 2^31 - 1}
283
284Q27: Generics
285A: The purpose of generics in Java is to provide Type Safety and to resolve Type Casting problems.
286TypeSafety: by default collections are not type safe. That means you can store any type of value using collections if you are using this syntax (List list = new ArrayList()) but while fetching the value you need to typecast every time otherwise you will get an error.
287Eg:
288list.add("zudo") ;
289String s = (String) list.get(0); // No error
290Type Casting every element is a headache so Generics comes in to play. If you specify the type of data you are going to store in collections then you are not required to typecast at all.
291Generics declaration: List<String> list = new ArrayList<>(); // Now this array list will only store string elements so no TypeCasting is required and is Type Safe.
292Source: https://www.youtube.com/watch?v=BuH-uOwDGjY
293
294Q28: Scanner vs BufferedReader
295A: Memory: Scanner accepts only up to (1kb or 1024 chars) while BufferedReader accepts up to (8kb or 8192 chars)
296Functionality: Scanner accepts all kinds of inputs because it parse the data(String, int, double, etc using nextLine(), nextInt(), etc ) while BufferedReader only accepts Strings as input using readLine() method.
297Performance: BufferedReader is faster than Scanner because BufferedReader does not need to parse the data.
298Synchronization: BufferedReader is synchronized while Scanner is not. For multi-threading applications BufferedReader is preferred.
299Package : BufferedReader class is present in java.io package while Scanner class is present in java.util package.
300
301Q32: How to get Day, Month and Year from the specified date?
302A: import the "java.time" package. It contains number of classes and methods that can be used for representing date.
303import java.time.LocalDate;
304LocalDate date = LocalDate.of(year, month, day);
3051: date.getDayOfWeek() // Result: Day eg: TUESDAY
3062: date.getYear() // Result: Year - eg: 2019
3073: date.getDayOfMonth // Result: date - eg: 12
3084: date.getMonth() // Result: Month - eg: NOVEMBER
3095: date.getMonthValue() // Result: Month number - eg: 11
310
311Q34: StringBuilder()
312The StringBuilder in Java represents a mutable sequence of characters. Since the String Class in Java creates an immutable sequence of characters, the StringBuilder class provides an alternative to String Class, as it creates a mutable sequence of characters.
313StringBuilder() creates an empty string Builder with the initial capacity of 16.
314StringBuilder(String str) creates a string Builder with the specified string.
315Declaration: StringBuilder sb = new StringBuilder("Hello");
316Methods in StringBuilder:
317append() - Adds at the end of the string. // Eg: sb.append("Java"); - O/p: Hello Java
318insert() - Inserts string at the specified index. // Eg: sb.insert(1, "Java"); - O/p HJavaello
319replace() - Replaces characters at the specified index. // Eg: sb.replace(1,3,"Java"); - O/p HJavalo
320delete() - This method is used to delete the string from the specified index to end index. // Eg: sb.delete(1, 3); - O/p: Hlo
321reverse() - This method reverses the String. // Eg: sb.reverse(); - O/p: olleH
322Note: StringBuffer() is another method that is similar to StringBuiler() but StringBuffer() is thread safe(synchronized) while StringBuilder() is not.
323
324Q35: Regex
325A: Regex stands for regular expression. A group of strings that follow a particular pattern is called as regex.
326Eg: Phone number follows a particular pattern. ie 10 numbers starting from 6 or 7 or 8 or 9
327Regex is present in java.util.Pattern package. //import java.util.regex.*;
328To search for a pattern do the following:
329String search = "aa";
330String s = "aabcdfedfa";
331Pattern p = Pattern.compile(search);
332Matcher m = p.matcher(s);
333while(m.find()){
334sysout(m.start() + " " + m.end() + " " + m.group());
335}
336Related methods:
337start() - method returns the starting index of the target string in the given string.
338end() - method returns the end index of the target string.
339group() - method returns the search string.
340boolean matches = Pattern.matches(pattern, text); OR s.matches(p);
341Some Pattern Matching rules:
342[abc] - matches either a or b or c
343[^abc] - matches everything except a, b and c
344[a - z] - matches any small letters from a - z
345[A - Z] - all capital letters
346[a-zA-Z] - all letters
347[0-9] - all numbers
348[a-zA-Z0-9] - all letters and numbers
349[^a-zA-Z0-9] - Except letters and numbers. Alpha Numerice ie special characters
350\s - space character
351\S - anything except space
352\d - any digit from 0 - 9
353\D - anything except digit
354\w - any word character [alpha numeric] [a-z A-Z 0-9_]
355\W - anything except alpha numeric ie special characters
356. - any symbol including special character + space
357Quantifiers in Java:
358Quantifiers are used to find the number of occurances to match.
359a - : matches exactly one a
360a+ : at least one a or any number of a's
361a* : any number of a's or none
362a? : at most one a or none
363Eg: Pattern p = Pattern.compile("a");
364Matcher m = p.matcher("aabbabbab");
365//Result: it returns the index of every occurance of a
366How to represent a 10 digit or 11 or 12 digit mobile number?
36710 digit: [6-9][0-9]{9}
36811 digit: 0?[6-9][0-9]{9} // 0? here means 0 can or cannot occur.
36912 digit: (0|91)?[6-9][0-9]{9} // the number here can either start with 0 or 91
370Regular expressions to represent an email id
371Eg: contact@abc.com or contact@abc.co.au etc
372[a-zA-Z0-9][a-zA-Z0-9._]*@[a-zA-Z0-9]+([.][a-zA-Z]+)+
373
374Q36: StringTokenizer
375A: It splits the string into tokens. By default it splits by space.
376Declaration:
377StringTokenizer st = new StringTokenizer("Hello split me");
378To split by any specific character use: new StringTokenizer("22-11-2019", "-"); //output 22 11 2019 (each word in new line)
379while(st.hasMoreTokens()){
380Sysout(st.nextToken());
381} //output: hello split me(each word in new line)
382
383Q37: PrintWriter
384A: It is the most enhanced writer to write character data to the file. The main advantage of PrintWriter over FileWriter or BufferedWriter is we can write any type of primitive data directly to the file.
385
386Q38: BigDecimal
387A: The BigDecimal class provides operations on double numbers for arithmetic, scale handling, rounding, comparison, format conversion and hashing. It can handle very large and very small floating point numbers with great precision but compensating with the time complexity a bit.
388It is included in java.math.BigDecimal;
389Eg: Dealing with very small values can lead to unusual answers.
390 double a = 0.03;
391 double b = 0.04;
392 double c = b-a;
393 System.out.println(c); // Output: 0.010000000000000002 or 0.009999999999999998
394Use of BigDecimal here gives the desired result.
395Eg: BigDecimal a = new BigDecimal("0.03");
396 BigDecimal b = new BigDecimal("0.04");
397 BigDecimal c = b.subtract(a);
398 System.out.println(c); // Output : 0.01
399
400Q39: BigInteger
401A: BigInteger class is used for the calculations of big numbers that are outside of the range of all the data types.
402It is included in java.math.BigInteger;
403Declaration: It accepts only string as input.
404BigInteger bi = new BigInteger("47486456887");
405Method: BigInteger.valueOf(4896456); //It takes integer as input
406
407Q39: Addition, Subtraction, Multiplication, etc using methods. [Note: These doesn't work with primitive data types]
408A: These methods only work with BigInteger, BigDecimal
409int a = 5; int b = 6; int result;
410Addition: result = a.add(b); // 5 + 6 = 11
411Subtraction: result = a.subtract(b); // 5 - 6 = -1
412Multiplication: result = a.multiply(b); //5 * 6 = 30
413Division: result = a.divide(b); // 5 / 6 = 0;
414Power: result = a.pow(b); // 5^6 = ?
415
416Q40: Bitwise operators(&, | etc)
417A: These operators performs the operations(converts the given number in binary, then performs the specified operation) and returns the value in decimal form.
418Eg: OR (|)
419a = 5 = 0101 (In Binary)
420b = 7 = 0111 (In Binary)
421Bitwise OR Operation of 5 and 7
422 0101
423| 0111
424 ________
425 0111 = 7 (In decimal)
426Code: int a = 5, b = 6;
427int result = a | b; sysout(result); // 7
428Other Operators:
429& - Bitwise AND operator: Returns true(1) if both the values are 1
430^ - Bitwise XOR operator: Returns true if both the values are different. Eg: 10 = true, 11 = false
431~ - Bitwise Compliment operator: Returns the opposite of the input. Eg: 1011 = 0100
432Important Extras: use Integer.bitCount() to count the number of bits(1's) in the given number. Eg: Integer.bitCount(15) // Result = 4 because in 15(1111) there are 4 1's.
433
434Q41: Run-time Analysis of Algorithms
435A: Analysis of algorithms is performed to describe the performance or complexity(effeciency) of an algorithm. We can define the worst-case, best case or the avg case scenario for a given algorithm.
4361: Omega(Ω): The run time of an algorithm will not be less than the given time.
4372: Big-O(O): The run time of an algorithm will not be more than the given time.
4383: Theta(θ): The run time of an algorithm will "on an avg" be equal to the given time. In some senarios, the run time will be higher or lower than the given time but on an avg it will be equal to the given time.
439
440Q43: Queue
441A: Queue is an Interface in Java. It is a part of the collections package. Queue stores the elements in FIFO manner. The first added element will be the first one to be removed.
442Declaration: Queue<Integer> q = new LinkedList<>();
443Methods:
444add() - this method is used to add an element at the end of the Queue.
445remove() - this method removes the first element in the Queue. It throws NoSuchElementException when no element exists.
446poll() - this method removes and returns the first element in the queue. It returns null if the queue is empty.
447peek() - this method is used to view the first element in the Queue without removing it.
448element() - this method is similar to peek(). It throws NoSuchElementException when the queue is empty.
449size() - this method return the number of elements in the queue.
450
451Q44: Stack
452A: Stack is a class which is a part of java collections framework. It is based on the basic principle of last-in-first-out.
453Declaration: Stack<Integer> stack = new Stack();
454Methods:
455push() - adds the element to the stack.
456pop() - removes the element from the stack.
457peek() - returns the element on the top of the stack, but does not remove it.
458empty() - returns true if the stack is empty else it returns false.
459search(element) - searches for the provided element in the stack and returns the position of the element from the top of the stack. This method starts the count index from 1 and not 0.
460
461Q45: Binary Heap
462A: Heap is a data structure that stores elements similar to the binary tree with additional properties. It is a complete tree in which all the levels are completely filled except possibly the last level where the elements are stored at the extreme left.
463There are two types of Binary Heap:
464Min Heap: The value of any node must be <= that of its children.
465Max Heap: The value of any node myst be >= that of its children.
466
467Q47: List of Lists
468A: Lists with in a list is nothing but storing different sets of list in one list.
469Declaration:
470ArrayList<ArrayList<Integer>> listOfLists = new ArrayList(); // list of lists
471ArrayList<Integer> listOne = new ArrayList(); // single listOne {let's say it contains [1, 2, 3]}
472ArrayList<Integer> listTwo = new ArrayList(); // single listTwo {let's say it contains [4, 5, 6]}
473listOfList.add(listOne); // added the first single list
474listOfList.add(listTwo); // added the second single list
475System.out.println(listOfLists); // [[1,2,3], [4,5,6]]
476
477Q48: Logarithms
478A: A logarithm is the power to which a number must be raised in order to get some other number.
479Understanding: How many times we should multiply 2 by itself to get 8?
4802 x 2 x 2 = 8. So, we do it 3 times to get 8. So, log2(8) = 3
481log5(625) = 4 (5 x 5 x 5 x 5)
482log2(64) = 6 (2 x 2 x 2 x 2 x 2 x 2)
483Formulas:
484Product ln(xy) = ln(x)+ln(y)
485Quotient ln(x/y) = ln(x)−ln(y)
486Log of power ln(x^y) = yln(x)
487Log of e ln(e) = 1 (the value of e in maths is 2.71828, it is called as Euler's number and it remains constant no matter what you do with it)
488Log of one ln(1) = 0
489Log reciprocal ln(1/x) = −ln(x)
490Source: https://www.mathsisfun.com/algebra/logarithms.html
491
492Q49: Different Algorithm Techniques
493A: These algorithm techniques have different approaches for solving a problem. Almost all kinds of problems can be solved using either of these techniques.
4941: Greedy Algorithm: It is an algorithmic paradigm that builds up a solution piece by piece. It always goes with the best option available at every step at that moment. It perfectly fits where solving small problems leads to a global solution.
495Examples: Suppose you want to build a wall but you only have broken bricks. Now at each step you choose the biggest available brick and continue to do same at every step. This will lead you to the final result and that is the wall.
496Examples of algorithms using greedy algorithm: Insertion sort, selection sort.
4972: Divide and Conquer: This technique works recurisvely by dividing the problem in to smaller sub-problems until they can be solved directly. Then the solutions of the sub-problems are combined to get the final solution.
498Examples of algorithms using greedy algorithm: Merge sort, quick sort, binary search, fibonacci series
4993: Dynamic Programming: While using divide and conquer technique, if the same sub-problems occur again and again then we apply dynamic programming technique to make our code more efficient. The solution of all the sub-problems are stored in an array and when we comes across the same sub-problem then we get the solution from the array.
500
501Q50: 3 Keys of Backtracking
502A: Let's take "generate all strings with n matched parantheses" problem as an example to understand these 3 keys.
5031: Our Choice: Either "(" or ")"
5042: Our Constraints: The number of open and closed brackets must be equals to n. And the closed bracket must not be used unless its corresponding open bracket is available.
5053: Our Goal: Length of the each string generated should be equal to n*2.
506
507Q51: PriorityQueue
508A: A priority queue is an abstract data type that operates similar to a normal queue except that each element has a certain priority.
509By default it stores the elements in sorted order.
510Declaration:
511 PriorityQueue<Integer> pq = new PriorityQueue();
512Methods: Mostly same as Queue.
513pq.add()
514pq.remove()
515pq.poll() // both remove and poll are same except when the queue is empty, poll will return null while remove will throw NoSuchElementException.
516pq.isEmpty()
517Note: The difference between PriorityQueue and TreeSet is: PQ stores even duplicates in sorted order(this order is achieved only while removing from the queue) where TreeSet doesn't store duplicates.
518
519Q52: Math.random();
520A: This method returns a number between 0 and 1;
521If you want to return an integer between zero and hundred, you would do: (int) Math.floor(Math.random() * 101)
522Between one and hundred, I would do: (int) Math.ceil(Math.random() * 100)
523In a range:
524int range = 10;
525(int) (Math.random() * range +1)
526In the general case:
527(int)(Math.random() * ((upperbound - lowerbound) + 1) + lowerbound);
528To generate a random number between 10 and 20
529int rand = (int)(Math.random() 11 + 10);
530Source: https://stackoverflow.com/questions/7961788/math-random-explanation
531
532Q53: Synchronization
533A: If a method is not synchronized then it is not thread safe which means multiple threads can use that method at the same time causing abnormal results. If the method is synchronized then only one thread can use the method at a time.
534
535Q54: Inheritance(IS-A) and Association(HAS-A)
536A: Inheritance: When a class A extends class B then this is called Inheritance and both of these classes are tightly coupled.
537Eg:
538Class Vehicle{
539}
540Class Car extends Vehicle{
541}
542Here Car is a(IS-A) Vehicle.
543Association: When a class B creates an instance of class A using new keyword then it is said to be Association.
544Eg:
545Class Engine{
546 int type;
547 int efficiency;
548}
549Class Car{
550 Engine e = new Engine();
551}
552Here Car has a(HAS-A) Engine
553Now using "e" object above, we can access all the properties or only the required properties of the class Engine. In case, in future, we want to use another engine then we can create an instance of that class and use it(not tightly coupled).
554Association has two concepts: Aggregation(weak bonding) and Composition(strong bonding).
555Source: https://www.youtube.com/watch?v=9nRblRcb35Y
556
557Q55: Exceptions
558A: An exception is an unwanted or unexpected event which occurs during the execution of the program i.e at the run time, that disrupts the normal flow of the program.
559Throwable is the parent class of Exception and Error class.
560Exceptions occurs because of our program. Error occurs because of lack of system resources(less ram, slow processor, etc).
561Exceptions can be handled by using try, catch and finally blocks. (catch can be used multiple times with just one try block). Finally block always executes after try block
562Exceptions can also be handled by throw and throws keywords.
563irrespective of occurrence of exception. Finally block even executes when you return something from try block.
564Exceptions are caused by programmers and are recoverable by the programmer(Exception handling) while Errors are not recoverable by the programmer.
565There are two types of Exceptions: Checked(compile time) and Unchecked(run time) | In case of Error only one type exists: Unchecked(run time)
566Checked Exception: The exceptions that are checked by the compiler during compile time.
567Eg: If you want to access a file then you create an object of File class with the address of your file. Though the file is present at the correct address the compiler says that FileNotFound exception may occur.
568Unchecked Exception: The exceptions that are ignored/does not check/cannot check by the compiler during compile time.
569throw is used for Unchecked exceptions. throws is used for checked exceptions.
570Hierarchy of exception: Img: https://funkyimg.com/i/31Yjo.png
571e.printStackTrace() - This method is used to print the (Exception name) (Description) (Stack pointer i.e line of the occurance)
572e.getMessage() - Prints only the description.
573e or e.toString() - Prints Exception name and the description.
574
575Awesome Source: https://www.youtube.com/playlist?list=PLlhM4lkb2sEjaU-JAASDG4Tdwpf-JFARN
576
577Q56: Difference between throw and throws
578A: Both of these are used to handle exceptions in Java.
579(throw) keyword is used to create an exception object manually i.e by the programmer. Eg: throw new definedException("text");
580(throws) keyword is used to declare exceptions in the method so that the caller method can handle that exception. Eg: void readFile() throws FileNotFoundException{}
581(throw) keyword is mainly used for runtime exceptions. It is used within method.
582(throws) keyword is mainly used to compile time exceptions. It is used with the method signature.
583(throw) we can only throw one exception.
584(throws) we can declare multiple exceptions. Eg: void readFile() throws FileNotFoundException, NullPointerException, etc..{}
585
586Q57: Static Block & Instance Block
587A: Static block is executed when ever an instance of the class is created.
588Ex:
589class StaticExample{
590 static{
591 System.out.println("Static: Hi!");
592 }
593 //instance block
594 {
595 System.out.println("Instance: Hi");
596 }
597}
598If the object of the above class is created then both static block and instance blocks are called.
599StaticExample se = new StaticExample(); // Static: Hi /n Instance: Hi
600
601Q58: Anonymous Class
602A: When the only purpose of a class is to Override a method then we use the concept of Anonymous class.
603Eg:
604class A{
605 public void printSomething(){
606 System.out.println("Hello from class A");
607 }
608}
609To override the printSomething() method of class A, generally we extend it and then Override it. Like this,
610class B extends A{
611 @Override
612 public void printSomething(){
613 System.out.println("Hello from class B");
614 }
615}
616Then we create the object of B to call that method. Like this,
617A obj = new B();
618obj.printSomething(); // Hello from class B
619Now instead of doing this we can use the Anonymous class technique to do same in a short way.
620Eg: Remove the class B and do the following instead.
621A obj = new A(){
622 public void printSomething(){
623 System.out.println("Hello from Anonymous class");
624 }
625};
626obj.printSomething(); //Hello from Anonymous class
627Note: Anonymous classess can also be used with interfaces.
628
629Q59: Comparator Interface
630A: This interface can be use to sort the objects in the user desired order.
631For example: if you want to sort these number[101, 115, 250, 424, 623] in order by their last two digits then make a class that extends Comparator Interface.
632import java.util.*;
633class ImpComparator implements Comparator<Integer>{
634 @Override
635 public int compare(Integer a, Integer b){
636 if(a%10 > b%10)
637 return 1; // 1 = swap
638 else
639 return -1; // -1 = no swap
640 }
641}
642ImpComparator com = new ImpComparator();
643Collections.sort(list, com);
644Now our list will be sorted by their last digit. Similarly you can modify the compare() method to sort the elements the way you want.
645
646Q60: Reading from a File
647A: A file can be read in different ways in Java. Below is the way to read a file using Scanner class.
648import java.io.*;
649import java.util.*;
650File file = new File("c:/Users/username/desktop/filename");
651Scanner sc = new Scanner(file);
652while(sc.hasNextLine()){
653 System.out.println(sc.nextLine());
654}
655//This program reads the file line by line and displays on to your console.
656sc.hasNext() can be used to read the file word by word.
657Source: https://bit.ly/2uV7a22
658
659-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
660-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
661Java Related: like Maven, Hibernate, Spring Boot, REST etc
662-----------------------------------------------------------------------
663
664Q1: What is Maven?
665A: Maven is a powerful project management tool that is based on POM (project object model). It is used for projects build, dependency and documentation. In short terms we can tell maven is a tool that can be used for building and managing any Java-based project. Maven makes the day-to-day work of Java developers easier.
666We can easily build a project using maven.
667We can add jars and other dependencies of the project easily using the help of maven.
668Maven provides project information (log document, dependency list, unit test reports etc.)
669With the help of Maven we can build any number of projects into output types like the JAR, WAR etc without doing any scripting.
670Using maven we can easily integrate our project with source control system (such as Subversion or Git).
671Img Source: https://media.geeksforgeeks.org/wp-content/uploads/How-Maven-Works.jpg
672
673Q2: About Spring
674A: Spring is a lightweight framework used to build Java applications.
675It is also considered as a framework of frameworks because it provides support to various frameworks such as Struts, Hibernate, Tapestry, EJB, JSF etc.
676Spring uses various new techniques such as Aspect-Oriented Programming (AOP), Plain Old Java Object (POJO), and dependency injection (DI), to develop enterprise applications.
677Spring framework replaced the EJB(Enterprise Java Beans) (EJB Defect: Applications were heavy weight and Tightly coupled; less secure).
678The Spring applications are loosely coupled because of dependency injection and are light weight.
679EJB was compared as Winter that is why Spring was named as Spring(Spring comes after Winter)
680Spring is not dependent on OS. It uses JDK libraries instead of OS libraries. (EJB has dependency of Application servers that is why they are heavy)
681Source: https://www.youtube.com/watch?v=YpsFT50mths&list=PLd3UqWTnYXOlc93disyBjyFv-r1Vq-5zh
682
683Q3: REST and SOAP
684A: Both of these are used to implement web services.
685Web Services ?: Application to application interaction over network. Platform independent.
686REST: Stands for Represential State Transfer
687Any web service that is defined on the principles of REST is called a RestFul web service.
688REST uses XML. JASON, text, etc format for implementation of web services.
689JAX-RS is a standard for implementing RESTful web services.
690
691SOAP: Stands for Simple Object Access Protocol
692SOAP uses only XML format for the implementation of web services.
693JAX-WS is a standard for impplementing SOAP web services.
694Notes: POST(create, send), PUT(update), GET(read), DELETE(delete)
695
696Q4: Hibernate
697A: Hibernate is an open-source and lightweight ORM tool that is used to store, manipulate, and retrieve data from the database.
698ORM: Object Relational Mapping is a strategy to map/store objects into database.
699HQL: Hibernate Query Language.
700Hibernate architecture has many interfaces such as Configuration, SessionFactory, Session, Transaction, etc.
701
702Q5: Servlets
703A: https://www.tutorialspoint.com/servlets/servlets-life-cycle.htm
704
705-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
706-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
707Useful Methods/Codes in Java:
708----------------------------------
709
710Q1: Integer.compare(a, b)
711A: This methods returns 0 if a == b; returns 1 if a > b; returns -1 if a < b;
712Eg: int a = 5, b = 5;
713 int result = Integer.compare(a, b);
714 System.out.println(result); //0 because here a = b
715
716Q2: Collections.sort(a);
717A: This method is present in the java.util.Collections class. It is used to sort the elements present in the specified list of Collection in ascending order. It works similar to Arrays.sort() method but it is better as it sorts lists, arrays, queues and more.
718Eg: Collections.sort(array or linkedlist);
719Other useful methods in the Collections class:
720max(Collection c): Returns the maximum element in c as determined by natural ordering. Eg: Collections.max(list name);
721min(Collection c): Returns the minimum element in c as determined by natural ordering.
722reverse(List list): Reverses the sequence in list.
723shuffle(List list): Shuffles (i.e., randomizes) the elements in list.
724
725Q3: indexOf()
726A: The indexOf() method returns the position of the first occurrence of specified character(s) in a string.
727There are 4 indexOf() methods:
728public int indexOf(String str)
729public int indexOf(String str, int fromIndex)
730public int indexOf(int char)
731public int indexOf(int char, int fromIndex)
732Eg1: Search a string for the first occurrence of "planet":
733public class MyClass {
734 public static void main(String[] args) {
735 String myStr = "Hello planet earth, you are a great planet.";
736 System.out.println(myStr.indexOf("planet"));
737 }
738} // output: 6 because in "planet" p starts from 6th index.
739Eg2: Find the first occurrence of the letter "e" in a string, starting the search at position 5:
740public class MyClass {
741 public static void main(String[] args) {
742 String myStr = "Hello planet earth, you are a great planet.";
743 System.out.println(myStr.indexOf("e", 5));
744 }
745} output: 10 because the first occurrence of "e" happens (after 5th index) at index 10;
746
747Q4: Arrays.toString(arr in);
748A: Returns the elements in the input array as a string. It is present in import java.util.*; package.
749Eg:
750int[] arr = {1, 2, 3, 7, 8, 11, 4, 5};
751sysout(Arrays.toString(arr)); //Outputs: [1, 2, 3, 7, 8, 11, 4, 5]
752
753Q5: toCharArray();
754A: toCharArray() method converts the given string into a sequence of characters. The returned array length is equal to the length of the string.
755Eg:
756String s = "Good Morning";
757char[] ch = s.toCharArray();
758for(char c: ch) {sysout(c)} // Good Morning(one char line by line)
759
760Q6: Convert String to Integer
761A: String num = "123";
762int numConverted = Integer.parseInt(num);
763Sysout(numConverted); // 123
764---
765To convert to double use Double.parseDouble();
766
767Q7: split()
768A: Suppose you have a string like [s = "11:22:33"] then you can use the split() method to split. You need an array to store the split elements.
769Eg: s = "11:22:33"
770String[] sArr = s.split(":"); //Result: sArr = {"11", "22", "33"}
771You can split space or any symbol. Just place the character you want to use to split between "". For space use string.split(" ");
772
773Q8: substring()
774A: This method is used to extract the substring from the given string. You can use this method for two purposes.
775Let's say String s = "hello";
776String s1 = s.substring(2); //Result: s1 = "llo"; {This stores the rest of the string from index 2}
777String s2 = s.substring(1, 4) // Result s2 = "ell"; {This stores the string from index 1 to index 4 - 1}
778
779Q9: Convert String to Char
780A: String s = "hello";
781char ch = charAt(0);
782Sysout(ch); // h
783
784Q10: Integer to String Conversion
785A: You can do that in the following ways.
786Let's say int num = 10;
787Method 1: String s1 = String.valueOf(num); // Result: s1 = "10";
788Method 2: String s2 = Integer.toString(num); // Result: s2 = "10";
789
790Q11: compareTo()
791A: This method is used to compare two strings lexicographically. It returns 0 if both the strings are equal else it returns either positive or negative value based on the alphabetical order.
792Eg: String A = "geek"; String B = "astro"
793int A.compateTo(B);
794//output here is 6 because [g - a] ie 7 - 1 = 6
795If we do int B.compareTo(A); // then the output will be 1 - 7 = -6
796Extras: int compareToIgnoreCase(String str) : This method compares two strings lexicographically, ignoring case differences.
797
798Q12: Convert Integer to Binary
799A: int n = 10;
800String s = Integer.toBinaryString(n); // 1010
801
802Q13: forEach() method
803A: forEach method is used to traverse each element in the ArrayList or LinkedList.
804Eg: List<Integer> list = new LinkedList();
805list.add(10);
806list.add(20);
807list.forEach(System.out::println); // Prints 10 \n 10
808or list.forEach((n) -> System.out.println(n));
809
810Q14: System.nanoTime();
811A: This method is used to get the execution time for any piece of code. It returns the current elapsed time during the execution of the program where ever it is used.
812Alternate Method: System.currentTimeMillis()
813Implementation:
814long startTime, endTime, elapsedTime;
815startTime = System.nanoTime(); //Stores the current time in startTime.
816for(int i = 0; i < 1000; i++){
817 int x = i;
818}
819endTime = System.nanoTime(); // Stores the current time in endTime.
820elapsedTime = endTime - startTime; // Thus elapsed time is store in elapsedTime variable.
821Note: Nano sec = 1/1 billion of a sec. Milli sec = 1 / 1000 of a sec. (Nano to Milli = Nano/1000000)
822
823Q15: charAt() for different data types.
824A: String s = "hello";
825 int x = s.charAt(0);
826 char ch = s.charAt(0);
827 System.out.println(ch + " " + x); //output = "h 104"
828
829Q16: Character.getNumericValue();
830A: This methods takes a single character as an input and returns its numeric value. What is numeric value? = 0 1 2 3 4 5 6 7 8 9 A(10), B(11), C(12), D(13), etc...
831Eg: int val = Character.getNumericValue('B'); // val = 11
832
833Q17: new String(char array)
834A: The constructor method in String class takes array of characters as input and converts them into String.
835Eg:
836 char[] ch = {'a', 'b' , 'c'};
837 String s = new String(ch);
838 System.out.println(s); //abc
839
840Q18: file.listFiles();
841A: This method is related to files. This method returns an array of objects of type File (the paths of files/folders) of the specified directory.
842Eg:
843import java.io.*;
844File file = new File("c:/Users/username/desktop/folder");
845File[] allFiles = file.listFiles();
846Now allFiles will contain all the File objects(paths of the files/folders) in the specified folder.
847To list the names of all the files/folders, follow this code
848for(File f: allFiles){
849 if(f.exists()){
850 System.out.println(f.getName());
851 }
852}
853//f.getPath() will display the complete paths of the files/folders
854//f.isDirectory() is used to check if it is a folder.
855Example Code: https://onlinegdb.com/H16RYu0NL
856
857Q19: Reduce lines / code to remember
858A: Follow these tricks to make your code concise.
859maxSum = Math.max(sum, maxSum);
860a + b > 0 ? 1 : 0;
861Height of a tree: return root==null ? 1 : 1 + Math.max(height(root.left), height(root.right));
862
863Q20: Arrays.asList();
864A: This method is used to add individual elements into an Array List OR an array of specific object type in to an Array List.
865Eg 1: Adding individual elements
866int a = 1, b = 2, c = 3;
867List<Integer> list = Arrays.asList(a, b, c); //Now the list contains [1, 2, 3];
868Eg 2: Adding from an Array.
869Integer[] arr = {1, 2, 3, 4, 6};
870List<Integer> list = Arrays.asList(arr); //Now the list contains [1, 2, 3, 4, 6];
871
872
873
874-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
875-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
876Do you know?
877---------------------
8781: In try block we always write risky code. In catch block we write handling code. That is why try-catch blocks are used.
8792: We can call static methods without creating an object. Eg: Math.abs(-11). Math classes are static.
8803: Convert String to char array: char[] c1 = s1.toCharArray(); // s1 is the string.
8814: String is a class in Java whose objects are immutable(once created the input cannot be changed). Sometimes strings is also referred as a data type or Array of characters.
8825: Get name of the super class: object.getClass().getSuperClass().getName();
8836: The access modifier must always be public when you are overriding/implementing a method of an interface.
8847: Permutations means the total number ways of arranging something(ex: "abc" - 3! = 6 ways)(formula = nPr where n = total letters and r = size). While in combinations: only one combination of these letters(ie abc or bac etc)
8858: How to calculate which year is a leap year: If the number is divisible by 4 and not divisible by 100 or If the number is divisible by 4 and 100 then it should also be divisible by 400.
8869: Find GCD of two numbers: gcd(a, b) { if a == 0 return b; return gcd(b%a, a) } or keep subtracting the smaller number from the bigger number until you get 0.
88710: Find LCM of two numbers: (a * b)/GCD(a, b)
88811: Mean = average; Median = middle value or average of middle values. Mode: a number that occurs most number of times.
88912: Constructors in Java do not have any return type. A class can have multiple constructors.
89013: Subsequence: Eg: "apple" subsequence = "ap", "al" "ale", "appe" etc. (a subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements)
89114: Static variables are instance of class and not objects. If one object changes the value of static variable then the value chages for all.
89215: We cannot create an object(instantiate) of an abstract/interface class.
89316: Singleton class: is a class whose only one instance can be created at any given time, in one JVM. A class can be made singleton by making its constructor private.
89417: ORM: Object relational mapping (storing the object into the database) (Hibernate is an ORM tool)
89518: Dependency: When a class in java makes an instance of another class then that class is said to have dependency on another class.
89619: Spring framework replaced the EJB(Enterprise Java Beans) (EJB Defect: Applications were heavy weight and Tightly coupled)
89720: EJB was compared as Winter that is why Spring was named as Spring(Spring comes after Winter)
89821: For lose coupling Java Runtime Polymorphism is used. Use an Interface instead of directly creating the object of A class in B class(tight coupling).
89922: Relationship between classes: Inheritance(IS-A) Association (HSA-A)
90023: Object class is the parent class of all the classes in Java. Throwable is the parent class of Exception class and Error class.
90124: Java MVC(Model is POJO, View is JSP, Controler is Servlet)
90225: Web Services: Application to application interaction over network. Platform independent. Any web service that is defined on the principles of REST is called a RestFul web service.
90326: SOAP: Simple Object Access Protocol | REST: Represential State Transfer
90427: Functional Interface: An interface with single abstract method is called functional interface. An example is java.lang.Runnable.
90528: Fork: fork happens when developers take a copy of source code from one software package and start independent development on it, creating a distinct and separate piece of software.
90629: SDLC: Software Development Life Cycle is a process used by the software industry to design, develop and test high quality softwares. The SDLC aims to produce a high-quality software that meets or exceeds customer expectations, reaches completion within times and cost estimates.
90730: In browers we use forward slash(/) to access paths, same with linux but in windows we use backward slash(\)
90831: Overloading is called as compile time polymorphism and Overriding is called as runtime polymorphism.
90932: Marker Interface: An interface that has no methods. Eg: Serializable Interface.
91033: Anagrams: An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.[1] For example, the word anagram can be rearranged into nag a ram, or the word binary into brainy or the word adobe into abode.
91134: Path access in windows through program: c:\\Users\\Rajan\\Desktop\\file.txt or c:/Uers/Rajan/Desktop/file.txt
91235: Modular Arithmetic: (a + b)%M = (a%M + b%M)%M || (a − b)%M = (a%M − b%M)%M
913
914-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
915Frequently Asked Algorithms:
916------------------------------------------
917Two Sum
918Level Order Traversal (Microsoft)
919BFS on Graph (Microsoft)
920Linked List Reversal (Microsoft)
921Reverse K groups in a LinkedList (Microsoft, AmDocs)
922
923
924-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
925-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
926Useful Links:
927------------------
9281: (Medium) Resources to learn Dynamic Programming: https://bit.ly/2t9P772
9292: (LeetCode) Dynamic Programming patterns post: https://bit.ly/3624ih5
9303: (System Design Github) https://github.com/donnemartin/system-design-primer
9314: (Buy Referrals) https://www.rooftopslushie.com/
9325: (System Design) https://www.educative.io/courses/grokking-the-system-design-interview
9336: (Quora System Design) http://www.bigfastblog.com/quoras-technology-examined
9347: (HackerRank wallbreakers interview training) https://bit.ly/35zeQDh
9358: (CTCI book) https://bit.ly/2ssdPiX
9369: (Amazon Online Assessment Q) https://bit.ly/2vgsCyh
93710: (DS & Algo Guide LeetCode) https://bit.ly/2RI8iic
93811: (Online Js editor) stackblitz.com
93912: (ABCD of System Design - Youtube) https://bit.ly/2v1drJs
94013: (Puzzles - Mathsisfun) https://www.mathsisfun.com/puzzles/
94114: (Resume, etc CareerCup) https://www.careercup.com/
94215: (Questions to ask to the Interviewer LeetCode | GitHub) https://bit.ly/2TQPptm | https://bit.ly/33dkuLY
94316: (Leadership Principles) https://www.youtube.com/channel/UCw0uQHve23oMWgQcTTpgQsQ/videos?pbjreload=10
944
945-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
946Things to Learn:
947------------------------
9481: Leadership Skills, STAR
9492: Other technologies JS + SQL + Spring Boot + j2ee
9503: Vector, synchronization, Lambda, Rest API, jdbc, Difference between threads and processes, HackerRank all, System Design.
9514: Amdocs: Linux, OSI model, TCP/IP model, STAR
952
953-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
954Interview Tips:
955----------------------
9561: Most interviewers are looking for candidates with a strong level of coding and ability to collaborate and learn.
9572: You being able to listen to their guidance throughout the interview is an important trait they're looking for.
9583: Interviewers do not expect the right answer. They are interested in how you approach the problem.
959
960Resume:
961Proofread your resume.
962For each role, try to discuss your accomplishments with the following approach: "Accomplished X by implementing Y which led to z:· Here's an example: "Reduced object rendering time by 75% by implementing distributed caching, leading to a 10% reduction in log-in time:·
963Not everything you did will fit into this approach, but the principle is the same: show what you did, how you did it, and what the results were.
964Languages: Java (expert}, C ++ (proficient), JavaScript (prior experience).
965
966https://javainterviewpoint.com/jersey-restful-web-services-generictype/
967https://writexo.com/raw/0ro244mk