- Java Compilers take Java source code and either turn it into machine code or turn it into Java byte code. They usually turn it into byte code.
- JVMs take Java Byte code as input. The Byte code telling JVM what to do. The output being whatever you programmed you Java program to output.
What
is SDK?
- Short for Software Development Kit, a programming package that enables a programmer to develop applications for a specific platform. Typically an SDK includes one or more APIs, programming tools, and documentation.
What Is Object?
- It represents the entities of the real world problem that the program is trying to solve from the building block of a program.
- The object of a program also called the instance of that class.
- Each object has a state that is a set of characteristics.
What is java bean?
- A getter method is used to obtain the value of the property from a bean.
- A setter method which is used to assign a value to a bean’s property.
- Each property of the java bean class is implemented by defining two public function (“get” function and “set” function).
Example:
public class
EmployeeInfo extends Service {
public EmployeeInfo(){}
private long employeeId;
public long getEmployeeId(){
return employeeId;
}
public void setEmployeeId(long employeeId){
this.employeeId=employeeId;
}
}
# “this”
ð Keyword is used to
pointing the current class instance.
ð It can be used with variables or methods.
ð It cannot be used inside a static method.
Example: class test{
private int i=10;
public void m(){
System.out.println(this.i);
}
}
#’ “Supper”
ð
Keyword is used for pointing the super class.
Example:
class A{
int
k=10;
}
class Test extends A{
public
void m(){
System.out.print(super.k);
}
}
# Static:
ð
Static variable belong to a class only they have
no relation to object
ð
The allocate memory when class is loaded at
runtime. That’s why we call them “class
variable”.
ð
It can be accessed by any method.
ð
A static method can access only static members.
#Non Static:
ð
Non static variable belongs to object.
ð
They allocate memory at compile time. It is
called “instance variable”.
ð
It can be accessed instance methods only.
ð
A non-static method can access both static and
non-static members because at the time when the static method is called, the
class might not be instantiated (if it is called on the class itself).
Example:
public class HowToAccessStaticMethod{
int
i;
static int j;
public static void staticMethod(){
System.out.println("you can access a static method this way");
}
public void nonStaticMethod(){
i=100;
j=1000;
System.out.println("Don't try to access a non static method");
}
public static void main(String[] args) {
//i=100;
j=1000;
//nonStaticMethod();
staticMethod();
}
}
No comments:
Post a Comment