Question 43)
Your chief Software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC.
The main difference between the two is that one runs the Linux operating System and the other runs the Windows System (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?
1) Give the goahead for further design using the current scheme
2) Ask for a re-design of the hierarchy with changing the Operating System to a field rather than Class type
3) Ask for the option of WindowsPC to be removed as it will soon be obsolete
4) Change the hierarchy to remove the need for the superfluous Computer Class.
Answer to Question 43)
--------------------------------------------------------------------------------
Question 44)
Which of the following statements are true
1) An inner class may be defined as static
2) There are NO circumstances where an inner class may be defined as private
3) An anonymous class may have only one constructor
4) An inner class may extend another class
Answer to Question 44)
--------------------------------------------------------------------------------
Question 45)
What will happen when you attempt to compile and run the following code
int Output=10;
boolean b1 = false;
if((b1==true) && ((Output+=10)==20)){
System.out.println("We are equal "+Output);
}else
{
System.out.println("Not equal! "+Output);
}
1) Compile error, attempting to peform binary comparison on logical data type
2) Compilation and output of "We are equal 10"
3) Compilation and output of "Not equal! 20"
4) Compilation and output of "Not equal! 10"
Answer to Question 45)
--------------------------------------------------------------------------------
Question 46)
Given the following variables which of the following lines will compile without error?
String s = "Hello";
long l = 99;
double d = 1.11;
int i = 1;
int j = 0;
1) j= i <
Answer
to Question 46)
--------------------------------------------------------------------------------
Question 47)
What will be output by the following line of code?
System.out.println(010|4);
1) 142) 03) 64) 12
Answer
to Question 47)
--------------------------------------------------------------------------------
Question 48)
Given the following variableschar 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;
Answer
to Question 48)
--------------------------------------------------------------------------------
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");
Answer
to Question 49)
--------------------------------------------------------------------------------
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;
Answer
to Question 50)