Tuesday, March 6, 2018

What is browser cache memory


In order to speed up web browsing, web browsers are designed to download web pages and store them locally on your computer's hard drive in an area called "cache". Browser cache (also know as Internet cache) contains records of every item you have viewed or downloaded while Internet surfing. So when you visit the same page for a second time, the browser speeds up display time by loading the page locally from cache instead of downloading everything again.

How to find cache folder

1. Click the “Start” button and click on “Control Panel.”
2. Choose “Appearance and Personalization,” then click on “Folder Options.”
3. Click the “View” tab and look under “Advanced Settings.”
4. Click the “Show Hidden Files and Folders” radio button and click “OK.”
5. Click the "Start" menu button, then click "Computer." Double-click your main hard drive, then click on “Users” and open the folder with your user name.
6. Navigate to the file path “\AppData\Local\Google\Chrome\User Data\Default\Cache.” The contents of Chrome's cache appear in this folder.

Monday, March 5, 2018

Marker Interface

http://mrbool.com/what-is-marker-interface-in-java/28557

Serialization

Serialization is a mechanism of converting the state of an object into a byte stream.
Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory.(https://www.geeksforgeeks.org/serialization-in-java/)

TALK-01

Short story about serialization
After many years of hard work, Earth's scientists developed a robot who can help them in daily work. But this robot had fewer features than the robots developed by the scientists from planet Mars.
After a meeting between both planets' scientists, it is decided that Mars will send their robots to Earth. But a problem occurred. The cost of sending 100 robots to Earth was $100 million. And it takes around 60 days of traveling.
Finally, Mar's scientists decided to share their secret with Earth's scientists. This secret was about the structure of class/robot. Earth's scientists developed the same structure on Earth itself. Mar's scientists serialized the data of each robot and sent it to earth. Earth's scientists deserialized the data and fed it into each robot accordingly.
This process saved them time in communicating a massive amount of data.
Some of the robots were being used in some defensive work on Mars. So their scientists marked some crucial properties of those robots as transient before sending their data to Earth. Note that the transient property is set to null (in case of reference) or to the default value (in case of the primitive type) when the object gets deserialized.
One more point noticed by Earth's scientists is that Mars's scientists asked them to create some static variables to keep details about the environment. These details are used by some robots. But Mars's scientists don't share these details. Because Earth's environment was different from Mars' environment.
Even though knowing about the robot class structure and having serialized data Earth's scientist were not able to deserialize the data which can make robots working.
Exception in thread "main" java.io.InvalidClassException:
SerializeMe; local class incompatible: stream classdesc
:

Mars's scientists were waiting for the complete payment. Once the payment was done Mars's scientists shared the serialversionUID with Earth's scientists. Earth's scientist set it to robot class and everything started working.
TALK-02

Serialization is usually used When the need arises to send your data over network or stored in files. By data I mean objects and not text.
Now the problem is your Network infrastructure and your Hard disk are hardware components that understand bits and bytes but not JAVA objects.
Serialization is the translation of your Java object's values/states to bytes to send it over network or save it.

This is analogous to how your voice is transmitted over PSTN telephone lines.


String to Date


String dojStr = "1971-07-15"; 
DateFormat df = new SimpleDateFormat( "yyyy-MM-dd" ); 
Date dojDate = null; 
dojDate = df.parse(dojStr);

VarArgs - Variable Argument

Can be add more method variable without initialize.

return_type  method_name(DataType... variableName){}


class A{
    public static void varArgsMethod(String... value){
       sysout("Hi");
   }
    psvm(){
       A.varArgsMethod("Welcome","Var","args"); //Can add zero or more argument
   }
}

Output - Hi

Rules

  • Only can be one Variable argument in method

             ex - public void run(String... walk, int... time){}; //Compile error


  • Variable Argument must be last

            ex - public void  walk(int x, int... y){}




Tuesday, February 27, 2018

What is different between static nested class and inner class(non-static class)

The main different is that,

Inner class requires - > Instantiation of outer class
static nested class    ->  Not Instantiation. Can directly access it.


Reference by -https://examples.javacodegeeks.com/java-basics/java-static-class-example/

static class  example

Wow Code-01

public class TestMain {

//Static class with static method
 public static class StaticNestedClass{
public static void staticNestedClass(){
System.out.println("StaticNestedClass");
}
}
 //Inner Class
public class InnerClass{
public void innerClass(){
System.out.println("Inner Class");
}
}

public static void main(String args[]){
//This is work because both class and method are static. Then we can directly call method
following bellow way
StaticNestedClass.staticNestedClass();
}

}

WOW CODE - 02

public class Application {
//There is two inner class call InnerClass And GO
public class InnerClass{
          public void innerClass(){
System.out.println("InnerClass");
}
public class GO{
public void go(){
System.out.println("go");
}
}
}

  //There is static class
public static class StaticClass{
public void staticClass(){
System.out.println("StaticClass");
}
}

//There is main method

public static void main(String[] args) {
 
   //If we need to call inner class
Application ap = new Application();

Application.InnerClass innerCls = ap.new InnerClass();
innerCls.innerClass();

//If we need to call inner inner class
Application.InnerClass.GO g = innerCls.new GO();
g.go();

//If we need to call static class
Application.StaticClass st = new StaticClass();
st.staticClass();
   
  //Or
  StaticClass st = new StaticClass();
st.staticClass();
  

}
}



Different between HashMap and HashTable in Java

Hash Table
Hash Table is synchronized;
There cannot be any null key or value


Hash Map

Map<Integer, String> testMap = new HashMap<Integer, String>();
Hash map not synchronized
There can be one null key and any null value
Has

Wednesday, February 21, 2018

Array and array List

https://www.geeksforgeeks.org/array-vs-arraylist-in-java/

SQL

ALIAS QUERY

Table User

ID  |  USER_ID  | USER_NAME | PHONE_NO | ADDRESS

Table Company

ID | COMPANY_NAME | USER_ID


Table alias
SELECT  ur.USER_ID , ur.USER_NAME , cm.COMAPANY_NAME FROM User AS ur , COMPANY as cm;

Column alias
SELECT USER_ID AS id ,USER_NAME AS name from m_agri_harvest .

--------------------------------------------------------------------------------------------------------------------------
UPPER AND LOWER

Select upper(USER_NAME) from User

Select lower(USER_NAME) from User


PRIMARY KEY VS UNIQUE KEY

Primary Key
   












Monday, February 19, 2018

Runtime and Complile time error

Compile time error - Check about the syntax
Run Time error       - Divide by zero like that.


I think of it in terms of errors, and when they can be caught.
Compile time:
string my_value = Console.ReadLine();
int i = my_value;
A string value can't be assigned a variable of type int, so the compiler knows for sure at compile time that this code has a problem
Runtime:
string my_value = Console.ReadLine();
int i = int.Parse(my_value);
Here the outcome depends on what string was returned by ReadLine(). Some values can be parsed to an int, others can't. This can only be determined at run time


Static Key work

The static keyword mainly use for memory management. It is a key word that are used for share the same variable or method of given class.
This is used for constant variable or method that is same for every instance of a class. In java ,if a field is declare static, then exactly a single copy of that  field is created and shared among all instances of that class.


If class has constant variable and method then we don't need to create that constant variable and method with every instance of class. That time we try to create one time that constant variable and method and refer those thing from all instance. starbuser with cripto

WOW
https://examples.javacodegeeks.com/java-basics/java-static-class-example/

Watch also another post.
What is different between static nested class and inner class(non-static class)

How to use Arrays.sort() in java

import java.util.Arrays;

public class ArrayEx {

public static void main(String args[]){

int[] myArray2 = new int[]{23,2,21,4,5};
Arrays.sort(myArray2);
for(int i =0;i<myArray2.length;i++){
System.out.println(myArray2[i]);
}


String[] names = new String[]{"Peter", "Patricia", "Hunter", "Sarah",
       "Gabe", "Gina", "Rob", "John", "Zoey", "Tammy", "Robert",
       "Sean", "Paschal", "Kathy", "Neleh", "Vecepia" };

Arrays.sort(names);

for(int a=0;a<names.length;a++){
System.out.println(names[a]);
}
}

}