//Note: Analysis the programs errors,outputs and Understand the Java static inner class var arg concepts
//[1]
class Staticdemo1{
public static void main(String arg[]){
Staticdemo50.demo();
System.out.println("No of arguments"+arg.length);
for(int i=0;i<arg.length;i++){
System.out.println(arg[i]);
}
}
public static void demo(){
System.out.println("hello i am static method");
}
static{
System.out.println("This will be printed first");
}
}
//[2]
class Outer{
int i=25;
public void display(){
Inner io=new Inner();
io.test();
System.out.println("Inner class object is created");
}
class Inner{
public void test(){
System.out.println("i="+i);
}
}
}
class Test2{
public static void main(String arg[]){
Outer ou=new Outer();
ou.display();
}
}
//[3]
class Bank{
public static void demo(int...a){
System.out.println("you send"+a.length+"parameters");
for(int i=0;i<a.length;i++){
System.out.println(a[i]);
}
}
}
class Vararg3{
public static void main(String arg[]){
Bank.demo();
Bank.demo(5);
Bank.demo(5,6,7);
}
}
No comments:
Post a Comment