Download Interview Questions on Java For Selenium - Software Testing Tutorials graphic type that can be scaled to use with the Silhouette Cameo or Cricut. An SVG's size can be increased or decreased without a loss of quality. All of our downloads include an image, Silhouette file, and SVG file. It should be everything you need for your next project. Our SVG files can be used on adhesive vinyl, heat transfer and t-shirt vinyl, or any other cutting surface
Answer : Local variable is declared inside method or constructor and it is limited for that method or constructor only. View more detail on local variable in java.
Local Variable Example :
public class JavaVariable {
public void Calc() {
// Local Variables.
int sum;
int item1 = 5;
int item2 = 7;
sum = item1 + item2;
System.out.println("Sum is : " + sum);
}
public static void main(String args[]) {
JavaVariable j = new JavaVariable();
j.Calc();
}
}
27 : What is a Instance Variable in java?
Answer : Instance Variable is declared parallel to method or constructor in class. It is visible for all methods and constructors of that class. View more detail on instance variable in java.
Instance Variable Example :
public class JavaVariable {
//Instance Variable.
int sum;
public void Calc() {
// Local Variables.
int item1 = 5;
int item2 = 7;
sum = item1 + item2;
System.out.println("Sum is : " + sum);
}
public static void main(String args[]) {
JavaVariable j = new JavaVariable();
j.Calc();
}
28 : What is a Class Variable in java?
Answer : Class variable is declared with static keyword in class parallel to methods and constructor. Class variable is initialized only once at the start of execution and destroyed on end of program. Class variable is also known as static variable. View more detail on class variable in java.
Class Variable Example :
public class JavaVariable {
//Class Variable
static String sumType = "Basket";
//Instance Variable.
int sum;
public void Calc() {
// Local Variables.
int item1 = 5;
int item2 = 7;
sum = item1 + item2;
System.out.println(sumType + " Sum is : " + sum);
}
public static void main(String args[]) {
JavaVariable j = new JavaVariable();
j.Calc();
}
29 : What is the difference between instance variable and class variable?
Answer :
Instance Variable :
- It is unique to each instance of the class.
- Declared without static modifier.
- Memory allocation, loading and initialization is done at run time.
- It is shared by all instances of the class.
- Declared with static modifier.
- Memory allocation is done at compile time, loaded at load time and they are initialized at class initialization time.
Answer : Access modifiers allows us to set access levels for variables, methods, classes and constructors in java. We can control access levels using access modifiers in java. View more details on different access modifiers in java.
Download Interview Questions on Java For Selenium - Software Testing Tutorials All SVG file downloads also come bundled with DXF, PNG, and EPS file formats. All designs come with a small business commercial license. These SVG cut files are great for use with Silhouette Cameo or Cricut and other Machine Tools.