what will happen when you attempt to compile and run the following code
class base{ protected int i = 99; } public class ab{ private int i=1; public static void main(string argv[]){ ab a = new ab(); a.hallow(); } abstract void hallow(){ system.out.println("claines "+i); } }
1) compile time error
2) compilation and output of claines 99
3) compilation and output of claines 1
4) compilation and not output at runtime
you have been asked to create a scheduling system for a hotel and catering organsiation.
you have been given the following information and asked to create a set of classes to represent it
on the catering side of the organsiation they have
head chefs
chefs
apprentice chefs
the system needs to store an employeeid, salary and the holiday entitlement
how would you best represent this information in javae been given the following information and asked to create a set of classes to represent it.
how would you best represent this information in java
1) create classes for head chef, chef, apprentice chef and store the other values in fields
2) create an employee class and derive sub classes for head chef, chef, apprentice chef and store the other values in fields.
3) create and employee class with fields for job title and fields for the other values.
4) create classes for all of the items mentioned and create a container class to represent employees
you need to read in the lines of a large text file containing tens of megabytes of data. which of the following would be most suitable for reading in such a file
1) new fileinputstream("file.name")
2) new inputstreamreader(new fileinputstream("file.name"))
3) new bufferedreader(new inputstreamreader(new fileinputstream("file.name")));
4) new randomaccessfile raf=new randomaccessfile("myfile.txt","+rw");
what will happen when you attempt to compile and run the following code?
public class inc{ public static void main(string argv[]){ inc inc = new inc(); int i =0; inc.fermin(i); i = i++; system.out.println(i); } void fermin(int i){ i++; } }
1) compile time error
2) output of 2
3) output of 1
4) output of 0
what will happen when you attempt to compile and run the following code?
public class agg{ static public long i=10; public static void main(string argv[]){ switch(i){ default: system.out.println("no value given"); case 1: system.out.println("one"); case 10: system.out.println("ten"); case 5: system.out.println("five"); } } }
1) compile time error
2) output of "ten" followed by "five"
3) output of "ten"
4) compilation and run time error because of location of default
given the following class
public class zeroprint{ public static void main(string argv[]){ int i =0; //here } }
which of the following lines if placed after the comment //here will print out 0.
1) system.out.println(i++);
2) system.out.println(i+'0');
3) system.out.println(i);
4) system.out.println(i--);
given the following code
class base {} class agg extends base{ public string getfields(){ string name = "agg"; return name; } } public class avf{ public static void main(string argv[]){ base a = new agg(); //here } }
what code placed after the comment //here will result in calling the getfields method resulting in the output of the string "agg"?
1) system.out.println(a.getfields());
2) system.out.println(a.name);
3) system.out.println((base) a.getfields());
4) system.out.println( ((agg) a).getfields());
what will happen when you attempt to compile and run the following code.
public class pvf{ static boolean paddy; public static void main(string argv[]){ system.out.println(paddy); } }
1) compile time error
2) compilation and output of false
3) compilation and output of true
4) compilation and output of null
which of the following statements are true?
1) the x,y coordinates of an instance of mouseevent can be obtained using the getx() and gety() methods
2) the x,y coordinates of an instance of mouseevent can be obtained using the x and y integer fields
3) the time of a mouseevent can be extracted using the gettime() method
4) the time of a mouseevent can be extracted using the getwhen method
given the following code import java.io.*; public class ppvg{ public static void main(string argv[]){ ppvg p = new ppvg(); p.fliton(); } public int fliton(){ try{ fileinputstream din = new fileinputstream("ppvg.java"); din.read(); }catch(ioexception ioe){ system.out.println("flytwick"); return 99; }finally{ system.out.println("fliton"); } return -1; } }
assuming the file ppvg.java is available to be read which of the following statements are true if you try to compile and run the program?
1) the program will run and output only "flytwick"
2) the program will run and output only "fliton"
3) the program will run and output both "fliton" and "flytwick"
4) an error will occur at compile time because the method fliton attempts to return two values
责任编辑:小草