Which of the following statements are true?
1) The default constructor has a return type of void
2) The default
constructor takes a parameter of void
3) The default constructor takes no
parameters
4) The default constructor is not created if the class has any
constructors of its own.
Which of the following statements are true?
1) All of the variables in an interface are implicitly static
2) All of
the variables in an interface are implicitly final
3) All of the methods in
an interface are implicitly abstract
4) A method in an interface can access
class level variables
Which of the following statements are true?
1 ) The String class is implemented as a char array, elements are
addressed using the stringname[] convention
2) The + operator is overloaded
for concatenation for the String class
3) Strings are a primitive type in
Java and the StringBuffer is used as the matching wrapper type
4) The size
of a string can be retrieved using the length property
Which of the following statements are true?
1) A method in an interface must not have a body
2) A class may extend
one other class plus at most one interface
3) A class may extends at most
one other class plus implement many interfaces
4) An class accesses an
interface via the keyword uses
Which of the following statements are true?
1) The following statement will produce a result of 1. System.out.println( -1
>>>2);
2) Performing an unsigned left shift (<<<) on a
negative number will always produce a negative number result
3) The
following statement will produce a result of zero, System.out.println(1
>>1);
4) All the integer primitives in java are signed numbers
Which of the following statements are true?
1) The elements in a Java array can only be of primitive types, not objects
2) Arrays are initialized to default values wherever they are created
3)
An array may be dynamically resized using the setSize method
4) You can find
out the size of an array using the size method
Given the following class
public class Ombersley{
public static void main(String argv[]){
boolean b1 = true;
if((b1 ==true) || place(true)){
System.out.println("Hello Crowle");
}
}
public static boolean place(boolean location){
if(location==true){
System.out.println("Borcetshire");
}
System.out.println("Powick");
return true;
}
}
What will happen when you attempt to compile and run it?
1) Compile time error
2) Output of "Hello Crowle"
3) Output of
Hello Crowle followed by Borcetshire and Powick
4) No output
You are given a class hierarchy with an instance of the class Dog. The class Dog is a child of mammal and the class Mammal is a child of the class Vertebrate. The class Vertebrate has a method called move which prints out the string "move". The class mammal overrides this method and prints out the string "walks". The class Dog overrides this method and prints out the string "walks on paws". Given an instance of the class Dog,. how can you access the ancestor method move in Vertebrate so it prints out the string "move";
1) d.super().super().move();
2) d.parent().parent().move();
3)
d.move();
4) none of the above;
Which of the following most closely describes the process of overriding?
1) A class with the same name replaces the functionality of a class defined
earlier in the hierarchy
2) A method with the same name completely replaces
the functionality of a method earlier in the hierarchy
3) A method with the
same name but different parameters gives multiple uses for the same method name
4) A class is prevented from accessing methods in its immediate ancestor
Which of the following statements are true?
1) The % is used to calculate a percentage thus: 10 % 20=50
2) The /
operator is used to divide one value by another
3) The # symbol may not be
used as the first character of a variable
4) The $ symbol may not be used as
the first character of a variable
Which of the following statements are true?
1) The default layout manager for an Applet is FlowLayout
2) The default
layout manager for a Frame is FlowLayout
3) A layout manager must be
assigned to an Applet before the setSize method is called
4) The FlowLayout
manager attempts to honor the preferred size of any components
Which of the following statements are true about a variable created with the
static modifier?
1) Once assigned the value of a static variable may not
be altered
2) A static variable created in a method will keep the same value
between calls
3) Only one instance of a static variable will exist for any
amount of class instances
4) The static modifier can only be applied to a
primitive value
Which of the following statements are true?
1) Java uses a system called UTF for I/O to support international character
sets
2) The RandomAccessFile is the most suitable class for supporting
international character sets
3) An instance of FileInputStream may not be
chained to an instance of FileOutputStream
4) File I/O activities requires
use of Exception handling
What will happen when you attempt to compile and run the following code?
import java.io.*;
class ExBase{
abstract public void martley(){
}
}
public class MyEx extends ExBase{
public static void main(String argv[]){
DataInputStream fi = new DataInputStream(System.in);
try{
fi.readChar();
}catch(IOException e){
System.exit(0);
}
finally {System.out.println("Doing finally");}
}
}
1) Compile time error
2) It will run, wait for a key press and then
exit
3) It will run, wait for a keypress, print "Doing finally" then
exit
4) At run and immediately exit
What will happen when you attempt to compile and run the following code
public class Borley extends Thread{
public static void main(String argv[]){
Borley b = new Borley();
b.start();
}
public void run(){
System.out.println("Running");
}
}
1) Compilation and run but no output
2) Compilation and run with the
output "Running"
3) Compile time error with complaint of no Thread target
4) Compile time error with complaint of no access to Thread package
Assuming any exception handling has been set up, which of the following will create an instance of the RandomAccessFile class
1) RandomAccessFile raf=new RandomAccessFile("myfile.txt","rw");
2)
RandomAccessFile raf=new RandomAccessFile( new DataInputStream());
3)
RandomAccessFile raf=new RandomAccessFile("myfile.txt");
4) RandomAccessFile
raf=new RandomAccessFile( new File("myfile.txt"));
Given the following class definition
public class Upton{
public static void main(String argv[]){
}
public void amethod(int i){}
//Here
}
Which of the following would be legal to place after the comment //Here
?
1) public int amethod(int z){}
2) public int amethod(int i,int
j){return 99;}
3) protected void amethod(long l){ }
4) private void
anothermethod(){}
Which of the following statements are true?
1) Code must be written to cause a frame to close on selecting the system
close menu
2) The default layout for a Frame is the BorderLayout
Manager
3) The layout manager for a Frame cannot be changed once it has been
assigned
4) The GridBagLayout manager makes extensive use of the the
GridBagConstraints class.
Given the following class definition
public class Droitwich{
class one{
private class two{
public void main(){
System.out.println("two");
}
}
}
}
Which of the following statements are true
1) The code will not compile because the classes are nested to more than
one level
2) The code will not compile because class two is marked as
private
3) The code will compile and output the string two at runtime
4)
The code will compile without error
Given the following code
class Base{
static int oak=99;
}
public class Doverdale extends Base{
public static void main(String argv[]){
Doverdale d = new Doverdale();
d.amethod();
}
public void amethod(){
//Here
}
}
Which of the following if placed after the comment //Here, will compile and modify the value of the variable oak?
1) super.oak=1;
2) oak=33;
3) Base.oak=22;
4) oak=50.1;