Part 2

interface Shape{
public String baseclass="shape";
public void draw();
}
protected  class Circle implements Shape{
public void draw(){
System.out.println(" drawing trangle here");

}
}
public class Test {

public static void main(String[] args) {

Shape squreShape=new Circle();
squreShape.draw();

}

}

Output :   ?????????

-----------------------------------------------------------------------------------------------------------------



class Thread1 implements Runnable{
public void run(){
for(int i=0;i<10;i++){
try{
Thread.sleep(27);
}
catch(InterruptedException e){
e.printStackTrace();
}
System.out.println("Inside Thread "+i);
}
}
}

public class Test {

public static void main(String[] args) {
Thread t1=new Thread(new Thread1());
t1.start();
try{
t1.join(5000);
}
catch(InterruptedException e){
e.printStackTrace();
}

}

}

Output :   ?????????

-----------------------------------------------------------------------------------------------------------------



class Demo1a{
int num =35;
void myFunction(){
System.out.println("inside parent ");
}
}

class Demo1b extends Demo1a{
int num=45;
public void myFunction(){
System.out.println("inside child ");
}
}

public class Test {

public static void main(String[] args) {

Qsn1      obj1 = new DemoQ1b();
DemoQ1b   obj2 = new Qsn1();
Qsn1      obj3 = new Qsn1();
DemoQ1b   obj4 = new DemoQ1b();

}

}

Output :   ?????????

-----------------------------------------------------------------------------------------------------------------


class A{
            public static void main(String [] args)
             {
                    hello(null);
              }
               public static void hello(String str)
              {
                  sop("hello of string ");
               }
               public static void hello(Object obj)
              {
                  sop("hello of Object  ");
               }
}

Output :   ?????????

-----------------------------------------------------------------------------------------------------------------

class A{
public static void main(String[] args) {

hello(null);

}
public static void hello(Object obj)
{
System.out.println(" hello from object "+obj);
}


}


--------------------------------------------------------------------------------------------------------------
class A{
public static void main(String[] args) {

                HashMap<String , Integer> hm=new HashMap<>();
hm.put("a", 22);
hm.put("b", 52);
hm.put("a", 88);

for(Map.Entry h:hm.entrySet())
{
System.out.println(h.getKey()+" "+h.getValue());
}


Output :  ????????????????????
-----------------------------------------------------------------------------------------------------

public class Test {

public static void main(String[] args) {


String s="java";
String s1=s.replace('v', 'f');
s.concat("developer");
System.out.println(s);
System.out.println(s.concat(" xxx"));
System.out.println(s.toUpperCase());
System.out.println(s);
System.out.println(s1);
System.out.println((s+s1).concat(" j2ee"));
}

}

-------------------------------------------------------------------------------------------------------

0 comments:

Post a Comment