Code Snippets in JAVA Programming and their OUTPUTS-Day 2
CODE SNIPPETS OUTPUT
ACCESS MODIFIERS
Concepts: Data members are generally private and methods are public
class General
{
private int a=10;
public void show()
{
System.
out.
println("a = "+a);
}
}...
More
Code Snippets in JAVA Programming and their OUTPUTS-Day 2
CODE SNIPPETS OUTPUT
ACCESS MODIFIERS
Concepts: Data members are generally private and methods are public
class General
{
private int a=10;
public void show()
{
System.
out.
println("a = "+a);
}
}
class Test
{
public static void main (String [] args)
{
General g=new General();
g.
show();
}
}
a = 10
class General
{
private a=10;
public void show()
{
System.
out.
println("a = "+a);
}
}
class Test
COMPILE TIME ERROR
<identifier> expected
private a=10;
Less