Android apps to use in appium android test examples

Breaking

Wednesday, September 20, 2017

Interview Questions on Java For Selenium

Part 6

26 : What is local variable inward java?
Answer : Local variable is declared within method or constructor in addition to it is express for that method or constructor only. View more detail on local variable inward java.

Local Variable Example :
public course of written report JavaVariable {   populace void Calc() {   // Local Variables.   int sum;   int item1 = 5;   int item2 = 7;   amount = item1 + item2;   System.out.println("Sum is : " + sum);  }   populace static void main(String args[]) {   JavaVariable j = novel JavaVariable();   j.Calc();  } }



27 : What is a Instance Variable inward java?
Answer : Instance Variable is declared parallel to method or constructor inward class. It is visible for all methods in addition to constructors of that class. View more detail on instance variable inward java.

Instance Variable Example :
public course of written report JavaVariable {  //Instance Variable.  int sum;   populace void Calc() {   // Local Variables.   int item1 = 5;   int item2 = 7;   amount = item1 + item2;   System.out.println("Sum is : " + sum);  }   populace static void main(String args[]) {   JavaVariable j = novel JavaVariable();   j.Calc();  }

28 : What is a Class Variable inward java?
Answer : Class variable is declared alongside static keyword inward course of written report parallel to methods in addition to constructor. Class variable is initialized exclusively i time at the showtime of execution in addition to destroyed on halt of program. Class variable is likewise known equally static variable. View more detail on course of written report variable inward java.

Class Variable Example :
public course of written report JavaVariable {  //Class Variable  static String sumType = "Basket";   //Instance Variable.  int sum;   populace void Calc() {   // Local Variables.   int item1 = 5;   int item2 = 7;   amount = item1 + item2;   System.out.println(sumType + " Sum is : " + sum);  }   populace static void main(String args[]) {   JavaVariable j = novel JavaVariable();   j.Calc();  }

29 : What is the deviation between instance variable in addition to course of written report variable?
Answer :

Instance Variable :
  • It is unique to each event of the class.
  • Declared without static modifier.
  • Memory allocation, loading in addition to initialization is done at function time.
Static Variable :
  • It is shared past times all instances of the class.
  • Declared alongside static modifier.
  • Memory allotment is done at compile time, loaded at charge fourth dimension in addition to they are initialized at course of written report initialization time.
30. What is access modifier inward java?
Answer : Access modifiers allows us to gear upward access levels for variables, methods, classes in addition to constructors inward java. We tin command access levels using access modifiers inward java. View more details on dissimilar access modifiers inward java.

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/

No comments:

Post a Comment