Saturday, June 14, 2014

Learning Java - What does the ‘static’ keyword mean?

Static means a variable of the class and not the object of a class.

For example:
public class StaticExample {
      public static String name = "noob.. I am a static variable";
}
We have another class where-in we intend to access this static variable just defined.
public class Application {
        public static void main(String[] args) {
            System.out.println(StaticExample.name)
        }
}
We don’t create object of the class StaticExample
to access the static variable. We directly use the class name itself: StaticExample.name

static has not state, so dont need an object

static method can be a constructor/

no need to create an object.

good for use in a factory - pass in params - get the correct object back.

disadvantage.

cant be used in interface. so kind of limiting functionality to implementation in the code.

Statics methods are good for things like singletons where access to the constructed object needs to be controlled.

What is the Difference between JDK and JRE?

JDK :

Java Development Kit. -  is a bundle of software that you can use to develop Java based software.

JRE :

The Java Run-time Environment. I.e, the JRE is an implementation of the Java Virtual Machine which actually executes Java programs.

you need an java compiled app and a jre to run the java app.

JDK

 each JDK contains one (or more) JRE’s along with the various development tools like the Java source compilers, bundling and deployment tools, debuggers, development libraries, etc.

What is a JVM ?

JVM java virtual machine

What ?

intepreter - accepts byte code, and executes it

Why ?

platform independent
compile once- run anywhere (in theory)

compiler produces bytecode - its optimized and is executable by JVM

why bytecode ?

so  we have a a different jvm for each hardware/ os platform it will run the bytecode on the platform

so although its platform independent , java still needs a JVM - virtual machine for each system it runs on


Panic, I have an interview

I better get stuck-in to the studying, need to get a job in another country so I can get out of the company I am in, but mainly for my family who are depending on me to get them home.

Lot of shit to cover - java is so huge.

will start with random googling of interview questions, this generally shows me what I dont know.

ridiculous -I have been programming for 20 years,

8 years in java in stock brokerage software - exchange facing, but I have to go through the indignity of an interview.

biggest problem is that I cant talk about what I do, I just do it. Hell I don't talk to anyone except to ilicit business related logic and rules and then I code it and get it tested.

oh well on-wards.

on top of it I just had to team lead for 2 years - onyl 40% coding.

feck gotta get the jargon going.

ok remember boy, appear intelligent, likable, able top solve problems and answer there stuff right.