Please clarify the exercises in third module | Selenium Forum
M
Posted on 18/11/2015
Hi
I just started to learn Java so please bare with me. I have attached a document kindly go through it and clarification on code out puts in an email or written text next to the code would be really helpful.
Thank you in advance .

M
Replied on 18/11/2015

7) Will this code compile? // need clarification
[code:1emchxf8]
class Demo // Sub Class
{
static int var=9;
public static void func()
{
System.out.println("learning static keyword");
}
}
public class Main // Main class
{

public static void main(String s[])
{
Demo ob = new Demo();
ob.var=9;
ob.func();

}
}[/code:1emchxf8]
//Ans: ob.var=9; it can work but its not recommended.


you can access static method with object but its not recommended.