就业数据资源平台
当前位置:首页 > Java语言程序设计
JAVA题库:格林模拟试题二(下)6

  Question 48)
  Given the following variables
  char c = ’c’;int i = 10;double d = 10;long l = 1;String s = "Hello";
  Which of the following will compile without error?
  1)c=c+i;
  2)s+=i;
  3)i+=s;
  4)c+=s;
  Question 49)
  Which of the following will compile without error?
  1) File f = new File("/","autoexec.bat");
  2) DataInputStream d = new DataInputStream(System.in);
  3) OutputStreamWriter o = new OutputStreamWriter(System.out);
  4) RandomAccessFile r = new RandomAccessFile("OutFile");
  Question 50)
  Given the folowing classes which of the following will compile without error?
  interface IFace{}class CFace implements IFace{}class Base{}public class ObRef extends Base{    public static void main(String argv[]){        ObRef ob = new ObRef();        Base b = new Base();        Object o1 = new Object();        IFace o2 = new CFace();    }}
  1)o1=o2;
  2)b=ob;
  3)ob=b;
  4)o1=b;
  Question 51)
  Given the following code what will be the output?
  class ValHold{        public int i = 10;}public class ObParm{public static void main(String argv[]){        ObParm o = new ObParm();        o.amethod();        }        public void amethod(){                int i = 99;                ValHold v = new ValHold();                v.i=30;                another(v,i);                System.out.print( v.i );        }//End of amethod        public void another(ValHold v, int i){                i=0;                v.i = 20;                ValHold vh = new ValHold();                v =  vh;                System.out.print(v.i);        System.out.print(i);        }//End of another}
  1) 10030
  2) 20030
  3) 209930
  4) 10020
就业数据资源平台