NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Class : A class is a collection of objects and methods which enable its instances to have state and behavior. A class is an instance of itself.

Abstract Class : It is a class that cannot be instantiated but can be subclassed.  
Example : Animal ,Cat, Mouse

Abstract Method : An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon),

Class Vs. Object : An object is an instance of a class. A class could also be called as a template for an object. A class defines object properties.

Instantiation : It could be  called as creating an instance 

Method : Method is a subroutine associated with a class. Method define the behavior of the instance of a class. Methods have access to certain data at runtime.

Virtual Method : A virtual method is a function  or method whose behavior can be over ridden within an inheriting class by a function with the same signature.

Static Method : Static methods cannot implicitly access the data and they do not require an instance of the class.

Method/Function Overloading : Method overloading allows methods with same name that differ from each other in type of input or output of the function. Ability of one function to perform different tasks. Eg.  int doThisWith(x,y){return a;} 
double doThisWith(x,y,z){return b;}

Method overriding : When a subclass implements a method provided by the superclass it can override the method with same type and same return method and then the version of the child class will be executed.

Constructor : A constructor is a special type of sub routine of a class. It is called at the creation of an object of the class. It is called constructor because it constructs values of the data members of the class. 

Destructor :  It is an object which is automatically invoked when an object is destroyed.

Superclass : Superclass is a class that is being inherited.

Subclass : Subclass or a child class is a class that inherits one or more properties from the superclass or the base class .

Inheritance : Inheritance allows to derive classes which are derived from other classes so that they have some of its parent's members/functions as well as some of their own .

Encapsulation : Encapsulation can be called as a mechanism to restricting access to some of the objects components by use of proper access modifiers.

Abstraction: Hiding all but relevant data to reduce complexity and increase `efficiency.

Multiple Inheritance : In some programming languages a class can inherit more than one superclass which is called multiple inheritance in which the subclass contains methods and properties of all the inherited classes.

Forwarding/ Delegation : Forwarding is when letting another class/function decide on how to evaluate or solve a problem. Delegation is similar but a delegate has to exist to decide on who should be assigned to solve the problem.

Composition : It is a way of combining simple objects and data types into more complex ones. Ex. A house is composed of rooms, bed,etc. When the owning object is destroyed so are the contained objects.

Aggregation : Aggregation is similar to composition except that it does not imply ownership. If a university closes, the departments will close but the professor will still exist.

Polymorphism : It is the ability of an object or a function to exist in different forms .

Interface : An interface is a description of the actions that an object can do.

Method Signature : A method always is identified by its signature that includes method name , number and type of parameters.

Data Structure : Data structure is a particular of storing and organizing data in the program.

Struct : Struct is a structured type that aggregates a fixed set of objects of different types into one single object. 

Dependency Injection: Dependency Injection is the practice of passing in the object externally instead of creating it in the class or the constructor. Dependency injection makes testing easier.

4 Major Principles of Object-Oriented programming:
Encapsulation
Abstraction
Inheritance
Polymorphism

Java Garbage Collection
The garbage collector is used to get rid of objects that are not being used by the JVM/application. This frees up memory and increases performance. Basically it manages memory automatically for the lifecycle of a JVM. In C and C++ the memory management is done manually by the class. The classes have to release the memory manually by calling free and destroy methods.

Types of Data Structures : 

Data types (Primitive types) : Boolean, Char, Float, Double, Int, Enumerated type.

Data Types (Composite types) : Array, Record, Union, Tagged Union, Plain Old Data Structure.

Data types (Abstract Data Types) : Container, Map, MultiMap, List, Set, Multiset, Priority queue,Stack, Tree, Graph, String.

Linear Data Structures : Array,  Lists(linked List

Trees : Binary Trees, B-Tree, Heaps

Hashes, Graphs

Collection vs arrays
Collections can be mutable or immutable , arrays are mutable and not thread safe
Collection has different API, an array only has get/set by index and length

Arrays Vs LinkedList
Shuffling is a lot easier using a linkedlist
Arrays have a fixed size and the size needs to be known before creating it, linked list can be expanded dynamically.
Inserting an item in a linked list at a specific location is a lot easier than arrays.


Implementation Interface Descriptions Synchronized Allows Null
Collection Stores values/objects and cannot retrieve values using index
List Finer abstract form of a collection and can retrieve values using index
ArrayList List Concrete form of a collection and can retrieve values using index No Yes
LinkedList List Doubly linked list No Yes
Vector List Vector is like an array but is expandable like a list Yes Yes
Set Contains only unique values, does not retain ordering
SortedSet Contains only unique values and the values are added in a sorted order
TreeSet SortedSet Implementation for SortedSet. No
HashSet Set Implementation for Set backed by hashtable No Yes
Queue Objects are accessed in the order they are added.
Queue PriorityQueue Objects are accessed in the order they are added. FIFO No No
Map Stores values identified by key. only one null can be there.
SortedMap Stores the values in the map in a sorted manner
TreeMap SortedMap Stores the values in a sorted manner No Yes
Hashmap Map Store values identified by key, backed by hashtable. No Yes
LinkedHashMap Map Retains the insertion order and the iteration order is predictable No Yes
HashTable Map Stores values identified by key, backed by hashtable Yes Values only

Search/sort Algorithms and times

Type Best Performance Worst Performance
Binary Search Tree O(1) O(log n) For sorted arrays only. Compare with the element at the center and do that recursively by moving left or right and compare.
Quick sort O(nlog n) O(n^2) Use a Pivot to compare and move values within the list based on the pivot
Merge Sort O(nlog n) O(nlog n) Divide list in two halves recursively until it no longer can be divided and then compare and merge
Insertion Sort O(n) O(n^2) Compare elements to the rest of the list and move then to their appropriate spot accordingly
Bubble Sort O(n) O(n^2) Compare each paid of adjacent elements and move the greater one to the right. repeat until no swaps are made
Selection Sort O(n^2) O(n^2) Finds the smallest or the largest element based on the sorting type(asc, desc) and adds it to the sorted list
Heap Sort O(nlog n) O(nlog n) Heapifys the array and then moves the highest one to the top/highest parent and then moves that number to the end of the array

Enterprise Java Beans (EJB )

What is EJB?
EJB is an essential part of J2EE platform, EJB provides an architecture to develop and deploy component based enterprise applications.

What are the benefits of EJB?
Simplified development of large scale enterprise application.
The EJB container provides the necessary services like transactioning, security, load balancing, logging and persistence. The Developer can focus on just the business logic.
The container manager the creation and deletion of the ejb objects.

What is a session bean?
Session beans stores the data of a user for a session. Session beans can be stateful or stateless. Session beans use less resources than entity beans.

What is a stateful session bean?
A stateful session bean preserves the conversational state with the client. A stateful session bean keeps itself associated client with its instance variables. EJB container creates a separate stateful session bean for each client's request.

What is a stateless session bean?
A stateless session bean is type of session bean that does not maintain the conversational state and is normally used for independent operations. EJB container normally creates a pool of stateless session beans and uses these objects to process client requests.

What is an Entity bean ?
An entity bean represents persistent data storage. User data can be saved to the database using an entity bean and can be retrieved as an entity bean.

What is a message driven bean?
A message driven is invoked by the EJB container when it receives a message from queue or topic. Message driven beans are stateless and message driven bean tasks are performed asynchronously.

When is a local session bean used in EJB?
A local session bean is used when the ejb client is in the same environment where ejb session bean is deployed.

When is a remote session bean used in EJB?
A remote session bean is used when the ejb client is in a different environment than where the ejb session bean is deployed.

What are the key components of the persistence API?
Entity : A persistent object representing the data stored record, it is good to be serializable.
EntityManager : Persistence interface to perform CRUD operation. Also, executes query using Query interface.
Persistence unit(persistence.xml): Describes the properties of the persistence mechanism.
Data source(ds.xml): Describes the data source related properties, connection url , username, password.

What is a callback?
A callback is a mechanism by which the lifecycle of a bean can be intercepted.

What is a timer service in EJB?
Timer service is a mechanism used to build scheduled applications.

What is an EJB interceptor?
An interceptor method is called by ejb container before business method it is intercepting

What is a class level interceptor?
Class level interceptor are invoked before every method it is calling of that bean. Can be declared in the xml or as an annotation.

What is the default interceptor?
The default interceptor is invoked for every bean with in deployment. Can be applied only using ejb-jar.xml

What does ACID stand for?
Atomic, Consistent, Isolated and durable
Atomic: if one component fails everything fails. Success means all items completed successfully.
Consistent: A transaction must keep the system in consistent state
Isolated: Each transaction works independently of any other transaction
Durable: Transaction should survive system failure if it has been committed or executed.

What is JNDI?
JNDI stands for Java Naming Directory is used for naming and directory services.
JNDI binding is when you assign a name to an EJB which can be used later to lookup
Lookup refers to looking up and retrieving an object

@Stateful Used to declare a bean as stateful and the attributed are the same as stateless.
@Stateless used to declare a bean as stateless and the following attributes can be set on that annotation: name, mappedName, description
@MessageDriven The message driven annotation is used to declare a bean as messagedriven and the messageListenerInterface can be provided as an attribute messageListenerInterface
@Remote Used to specify remote interface of a session bean. This remote interface is used to expose the business methods to remote clients.
@Local Used to specify local interface of a session bean. This interface is used to expose the business methods to local clients.
@EJB The ejb annotation is to inject a depedency as ejb instance into another ejb. Name, beanName, beanInterface, mappedName and description are the attributes.
@Resource The annotation used to inject a datasource into an ejb
@ActiveConfigProperty Used to specify properties for a message driven bean propertyName, propertyValue
@PostActivate To specify callback method of an EJB lifecycle, is called when the bean gets activated or reactivated, used with stateful

@PrePassivate Method invoked when a bean is put back to the bean pool, used with stateful
@PostConstruct Method invoked when a bean is created. Can be used with stateless, stateful
@PreDestroy Method invoked before the bean is removed from the bean pool. Can be used with stateless, stateful

@Lob Provider support for Blob and Clob objects

RCP (Rich Client platform), SWT and JFace Questions:
What is included in a Rich Client Platform?
SWT, JFace, Eclipse Runtime, Workbench

What is OSGi?
Open Service Gateway initiative, It is used for developing modular java software and libraries

What is Display and what is Shell? The Display class represents the UI process and the Shell is the window itself.

What is SWT?
SWT is the standard Widget Toolkit and it is used to develop rich, efficient and potable GUI applications

General Coding Questions
Lock : A lock occurs when multiple processes are trying to access the same resource at the same time .

DeadLock :A deadlock occurs when a waiting process is holding on to a resource that an executing process needs to finish. 

X is using xbox, X and Y both want to use the PS3 but Y gets to use it first and now Y wants to use xbox but X is using xbox

Deadlock can be avoided by avoiding crossovers where processes are waiting for the same resource. Reduce the need to lock anything as far as possibly.

What are the scopes of programming languages and their uses?

Access specifier : public, private, protected

Public methods and functions can be accessed even from outside the class. 

private methods and function can be accessed only from within the class.

protected methods and functions 

Hiding information is about data not being directly accessible in the client program. 

const at the end of the function preceding the semi colon means the function will not modify the object on which they operate. 

How would you go about designing a program that determines whether or not a number is prime?

 Divide the number by every number between itself and 1. 

so for 7 divide 7 by 6,5,4,3 and 2

What is database normalization?

Database normalization is reducing redundant data and getting rid of duplicate entries and making sure data dependencies are valid, in other words it is the process of organizing data in a database. 

Unit testing : It is the smallest testable piece of a software or a program. Most of the times in OOD/OOP it is a class or a function. The complexity decides if it should be tested separately or with part of its class. 

unit testing has two phases. In the first phase you create a skeleton of a function/method with empty variables and placeholders. 

 the second one is initializing it and replacing the empty variables with appropriate ones. 

What is path coverage?

Path is a unique sequence of branches from entry to exit. Path coverage measures whether each of the possible paths in each functions are covered for testing. A very thorough testing is done using path coverage. White box testing. 

What is a diamond problem?

The diamond problem is an ambiguity problem of multiple inheritance where  B and C inherit from A and D inherits from B and C . If D calls a method from A and B and C have overridden that method differently then which method does D inherit? the one from B or the one from C 

what are the benefits of linked list vs a binary search tree?

Where do you see yourself in the next 7 years?

I do not have a specific plans but I plan to do my best to contribute to the success of any organization I work in. I am willing to learn new technologies and keep my eyes open within the organization to advance even it means changing roles.

Car paint relationship?

Car HAS-A paint and a car is not a paint. First is if the class color is named colors then it should not be named so. Classes should not have plural names. If paint is a different class then it could be because different car companies have different types of paints. A paint class could inherit some properties of color since every paint has some or the other color but it is not the other way round; every color is not a paint.

Memory leaks : Memory leak occurs when a computer program acquires memory to store objects/variables and fails to release it back to the operating system.

A memory leak can reduce the performance of a computer by reducing the amount of memory available.

Memory management : The basic requirement of memory management is allocating memory upon request and freeing it once it is no longer needed. 

embedded systems use fixed-size-block allocation

premature deallocation and incomplete deallocation :

incomplete deallocation includes freeing less than the memory that was allocated to a variable

Deallocating memory when it is not supposed to is called premature deallocation

What is MVC?

What are generics?

Generics enable types to be parameters when defining classes methods and interfaces. 

How will you improve your quality of code?

What is the difference between a set and a list ? 

A set is similar to a set in in mathematics. It does not take in duplicate value and does not have an index and is not ordered.

A list is ordered and has an index. It takes in duplicate value

Test case for replacing a String with a given string

public String replaceString(inputString, stringToReplace, replaceWith, replaceTimes){}

String in c++ is a good example of data abstraction because it tells us that the string is stored as a sequence of characters rather than telling us how it is stored in the memory 

Keyword const cannot change the value of the object.

Stack is for Value types and Heap is for reference types.


Static Vs Final (Method, Variable class) 

Static Variable
It is a variable which belongs to the class and not to object(instance)
Static variables are initialized only once , at the start of the execution . These variables will be initialized first, before the initialization of any instance variables
A single copy to be shared by all instances of the class
A static variable can be accessed directly by the class name and doesn’t need any object
Syntax : Class.variable

Static Method
It is a method which belongs to the class and not to the object(instance)
A static method can access only static data. It can not access non-static data (instance variables) unless it has/creates an instance of the class.
A static method can call only other static methods and can not call a non-static method from it unless it has/creates an instance of the class.
A static method can be accessed directly by the class name and doesn’t need any object
Syntax : Class.methodName()
A static method cannot refer to this or super keywords in anyway

Static Class
Java also has "static nested classes",A static nested class is just one which doesn't implicitly have a reference to an instance of the outer class.
Static nested classes can have instance methods and static methods.
There's no such thing as a top-level static class in Java.

Final
final keyword is used in several different contexts to define an entity which cannot later be changed.
A final class cannot be subclassed. This is done for reasons of security and efficiency. Accordingly, many of the Java standard library classes are final, for example java.lang.System and java.lang.String. All methods in a final class are implicitly final.
A final method can't be overridden by subclasses. This is used to prevent unexpected behavior from a subclass altering a method that may be crucial to the function or consistency of the class.
A final variable can only be initialized once, either via an initializer or an assignment statement. It does not need to be initialized at the point of declaration: this is called a blank final variable. A blank final instance variable of a class must be definitely assigned at the end of every constructor of the class in which it is declared; similarly, a blank final static variable must be definitely assigned in a static initializer of the class in which it is declared; otherwise, a compile-time error occurs in both cases.


Side Note:
main method is static since it must be be accessible for an application to run before any instantiation takes place.

Software Developer Questions

Binary Search O(log n): 

Searching an item in a list that is ALREADY SORTED can be performed by using an upper bound an d a lower bound and searching the item recursively by switching the upper and lower bounds.  

Duplicates in the list will have a significant negative impact on the performance. 

Access modifiers are used to encapsulate data/information. 

private: these fields and methods are accessible only to the class

protected: the current class or subclasses or current package will have access to these methods or fields

public: these fields/methods are accessible to any other class. 

What are java generics? 

Generics allows types to be parameters when defining classes and interfaces and methods 

Generics help eliminate casting and reduce the errors caused by casting or using objects


Stacks vs Queues

Stacks is a Last in first out form of container while queue is a first in first out form of container

Heap vs stack 

A stack is a more managed form of memory allocation while a heap is a less managed form of memory allocation which memory leaks are likely to occur if the memory being used is not freed after use. 

number 21 in binary 

21- 16 - 4- 1 = 10101


SQL

Types of database joins: 

Inner Join : This is a type of join in which entries in a column have a match in both  joined tables.  

Left outer join : This a type of join in which all entries from the left column will be displayed while the only the entries from the right column that match the entries from the left column will appear. 

Right outer join :  This a type of join in which all entries from the right column will be displayed while the only the entries from the left column that match the entries from the right column will appear.

Full outer join : All rows from the joined tables are included whether they have a match or not. 

Cross Join : A join whose result set include one row for each possible pairing of rows.

SQL Terms
Column : An individual piece of data stored in a table.
Row : A set of columns that together completely describe an entity or an action
Table : A set of rows, held either in memory or permanent storage.
Result Set : The result of an SQL query
Primary Key : one or more columns that can be used as a unique identifier for each row in a table.
Foreign Key : one or more columns that can be used to identify a single row in another table .
SQL Schema Statements : Used to define the data structures stored in a database.
SQL Data Statements : Used to manipulate the data structures previously stored
SQL Transaction Statements : Used to begin, end and roll back transactions

what is a stored procedure? 
A stored procedure is a set of one or more SQL statements. A stored procedure lets the user pass in parameters based on which the result data is returned. 

What is an index? 
Indexes are used to speed up queries. Indexing reduces the number of pages that are scanned when a query is executed. 

what is a SQL view? 
SQL view a virtual table based on a result set of a SQL statement

Types of relationships in SQL 
one-to-one, one-to-many, many-to-many, self referencing

What is a SQL union ?
Union merges two structurally same tables into one, union all does not delete duplicate records. 

Different types of joins in SQL :
Inner join: this is the default join and matches every row from table A that has a match on table B 
Left Join: This type of join will include all results from table A and only the matching results from table B
Right Join: this type of join will include all results from the right table and only those rows from left table that match 
Full join: gets all the records from both the tables and puts null in place of fields that do not have a match.
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.