Friday, September 16, 2011

Java Interview Questions - Part2


Java aptitude/interview questions - Part 2

Question 15) What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current directory?.
import java.io.*;
public class Mine {
public static void main(String argv[]){
Mine m=new Mine();
System.out.println(m.amethod());
}
public int amethod() {
try {
FileInputStream dis=new FileInputStream("Hello.txt");
}catch (FileNotFoundException fne) {
System.out.println("No such file found");
return -1;
}catch(IOException ioe) {
} finally{
System.out.println("Doing finally");
}
return 0;
}
}
1) No such file found
2 No such file found ,-1
3) No such file found, Doing finally, -1
4) 0
________________________________________
Question 16)
What tags are mandatory when creating HTML to display an applet
1) name, height, width
2) code, name
3) codebase, height, width
4) code, height, width
________________________________________
Question 17)
What will happen if you attempt to compile and run the following code?
1) Compile and run without error
2) Compile time Exception
3) Runtime Exception
class Base {}
class Sub extends Base {}
class Sub2 extends Base {}
public class CEx{
public static void main(String argv[]){
Base b=new Base();
Sub s=(Sub) b;
}
}
________________________________________
Question 18)
If the following HTML code is used to display the applet in the code MgAp what will
be displayed at the console?
1) Error: no such parameter
2) 0
3) null
4) 30
import java.applet.*;
import java.awt.*;
public class MgAp extends Applet{
public void init(){
System.out.println(getParameter("age"));
}
}
________________________________________
Question 19)
You are browsing the Java HTML documentation for information on the
java.awt.TextField component. You want to create Listener code to respond to focus
events. The only Listener method listed is addActionListener. How do you go about
finding out about Listener methods?
1) Define your own Listener interface according to the event to be tracked
2) Use the search facility in the HTML documentation for the listener needed
3) Move up the hierarchy in the HTML documentation to locate methods in base
classes
4) Subclass awt.event with the appropriate Listener method
________________________________________
Question 20)
What will be displayed when you attempt to compile and run the following code
//Code start
import java.awt.*;
public class Butt extends Frame{
public static void main(String argv[]){
Butt MyBut=new Butt();
}
Butt(){
Button HelloBut=new Button("Hello");
Button ByeBut=new Button("Bye");
add(HelloBut);
add(ByeBut);
setSize(300,300);
setVisible(true);
}
}
//Code end
1) Two buttons side by side occupying all of the frame, Hello on the left and Bye on
the right
2) One button occupying the entire frame saying Hello
3) One button occupying the entire frame saying Bye
4) Two buttons at the top of the frame one saying Hello the other saying Bye
________________________________________
Question 21)
What will be output by the following code?
public class MyFor{
public static void main(String argv[]){
int i;
int j;
outer:
for (i=1;i <3;i++)
inner:
for(j=1; j<3; j++) {
if (j==2)
continue outer;
System.out.println("Value for i=" + i + " Value for j=" +j);
}
}
}
1) Value for i=1 value for j=1
2) value for i=2 value for j=1
3) value for i=2 value for j=2
4 value for i=3 value for j=1
________________________________________
Question 22)
If g is a graphics instance what will the following code draw on the screen?.
g.fillArc(45,90,50,50,90,180);
1) An arc bounded by a box of height 45, width 90 with a centre point of 50,50, starting
at an angle of 90 degrees traversing through 180 degrees counter clockwise.
2) An arc bounded by a box of height 50, width 50, with a centre point of 45,90 starting
at an angle of 90 degrees traversing through 180 degrees clockwise.
3) An arc bounded by a box of height 50, width 50, with a top left at coordinates of 45,
90, starting at 90 degrees and traversing through 180 degrees counter clockwise.
4) An arc starting at 45 degrees, traversing through 90 degrees clockwise bounded by a
box of height 50, width 50 with a centre point of 90, 180.
________________________________________
Question 23)
Which of the following methods can be legally inserted in place of the comment //Method Here ?
class Base{
public void amethod(int i) { }
}
public class Scope extends Base{
public static void main(String argv[]){
}
//Method Here
}
1) void amethod(int i) throws Exception {}
2) void amethod(long i)throws Exception {}
3) void amethod(long i){}
4) public void amethod(int i) throws Exception {}
________________________________________
Question 24)
Which of the following will output -4.0
1) System.out.println(Math.floor(-4.7));
2) System.out.println(Math.round(-4.7));
3) System.out.println(Math.ceil(-4.7));
4) System.out.println(Math.Min(-4.7));
________________________________________
Question 25)
What will happen if you attempt to compile and run the following code?
Integer ten=new Integer(10);
Long nine=new Long (9);
System.out.println(ten + nine);
int i=1;
System.out.println(i + ten);
1) 19 followed by 20
2) 19 followed by 11
3) Error: Can't convert java lang Integer
4) 10 followed by 1
________________________________________
Question 26)
If you run the code below, what gets printed out?
String s=new String("Bicycle");
int iBegin=1;
char iEnd=3;
System.out.println(s.substring(iBegin,iEnd));
1) Bic
2) ic
3) icy
4) error: no method matching substring(int,char)
________________________________________
Question 27)
If you wanted to find out where the position of the letter v (ie return 2) in the string s
containing "Java", which of the following could you use?
1) mid(2,s);
2) charAt(2);
3) s.indexOf('v');
4) indexOf(s,'v');
________________________________________
Question 28)
Given the following declarations
String s1=new String("Hello")
String s2=new String("there");
String s3=new String();
Which of the following are legal operations?
1) s3=s1 + s2;
2) s3=s1-s2;
3) s3=s1 & s2
4) s3=s1 && s2
________________________________________
Question 29)
What is the result of the following operation?
System.out.println(4 | 3);
1) 6
2) 0
3) 1
4) 7
________________________________________
Question 30)
public class MyClass1 {
public static void main(String argv[]){ }
/*Modifier at XX */ class MyInner {}
}
What modifiers would be legal at XX in the above code?
1) public
2) private
3) static
4) friend
________________________________________
Question 31)
How would you go about opening an image file called MyPicture.jpg
1) Graphics.getGraphics("MyPicture.jpg");
2) Image image=Toolkit.getDefaultToolkit().getImage("MyPicture.jpg");
3) Graphics.openImage("MyPicture");
4) Image m=new Image("MyPicture");
________________________________________
Question 32)
An Applet has its Layout Manager set to the default of FlowLayout. What code would be correct to change to another Layout Manager.
1) setLayoutManager(new GridLayout());
2) setLayout(new GridLayout(2,2));
3) setGridLayout(2,2,))
4) setBorderLayout();
________________________________________
Question 33)
What will happen when you attempt to compile and run the following code?.
1) It will compile and the run method will print out the increasing value of i.
2) It will compile and calling start will print out the increasing value of i.
3) The code will cause an error at compile time.
4) Compilation will cause an error because while cannot take a parameter of true.
class Background implements Runnable{
int i=0;
public int run(){
while(true){
i++;
System.out.println("i="+i);
} //End while
}//End run
}//End class
________________________________________
Question 34)
You have created an applet that draws lines. You have overriden the paint operation and used the graphics drawLine method, and increase one of its parameters to multiple lines across the screen. When you first test the applet you find that the news lines are redrawn, but the old lines are erased. How can you modify your code to allow the old lines to stay on the screen instead of being cleared.
1) Override repaint thus
public void repaint(Graphics g){
paint(g);
}
2)Override update thus
public void update(Graphics g) {
paint(g);
}
3) turn off clearing with the method setClear();
4) Remove the drawing from the paint Method and place in the calling code
________________________________________
Question 35)
What will be the result when you attempt to compile and run the following code?.
public class Conv{
public static void main(String argv[]){
Conv c=new Conv();
String s=new String("ello");
c.amethod(s);
}
public void amethod(String s){
char c='H';
c+=s;
System.out.println(c);
}
}
1) Compilation and output the string "Hello"
2) Compilation and output the string "ello"
3) Compilation and output the string elloH
4) Compile time error
________________________________________
Question 36)
Given the following code, what test would you need to put in place of the comment line?
//place test here
to result in an output of
Equal
public class EqTest{
public static void main(String argv[]){
EqTest e=new EqTest();
}
EqTest(){
String s="Java";
String s2="java";
//place test here {
System.out.println("Equal");
}else
{
System.out.println("Not equal");
}
}
}
1) if(s==s2)
2) if(s.equals(s2)
3) if(s.equalsIgnoreCase(s2))
4)if(s.noCaseMatch(s2))
________________________________________
Question 37)
Given the following code
import java.awt.*;
public class SetF extends Frame{
public static void main(String argv[]){
SetF s=new SetF();
s.setSize(300,200);
s.setVisible(true);
}
}
How could you set the frame surface color to pink
1)s.setBackground(Color.pink);
2)s.setColor(PINK);
3)s.Background(pink);
4)s.color=Color.pink
________________________________________
Question 38)
How can you change the current working directory using an instance of the File class called FileName?
1) FileName.chdir("DirName")
2) FileName.cd("DirName")
3) FileName.cwd("DirName")
4) The File class does not support directly changing the current directory.
________________________________________
Question 39)
If you create a TextField with a constructor to set it to occupy 5 columns, what difference will it make if you use it with a proportional font (ie Times Roman) or a fixed pitch typewriter style font (Courier).
1)With a fixed font you will see 5 characters, with a proportional it will depend on the width of the characters
2)With a fixed font you will see 5 characters,with a proportional it will cause the field to expand to fit the text
3)The columns setting does not affect the number of characters displayed
4)Both will show exactly 5 characters
________________________________________
Question 40)
Given the following code how could you invoke the Base constructor that will print out the string "base constructor";
class Base{
Base(int i){
System.out.println("base constructor");
}
Base(){
}
}
public class Sup extends Base{
public static void main(String argv[]){
Sup s= new Sup();
//One
}
Sup()
{
//Two
}
public void derived()
{
//Three
}
}
1) On the line After //One put Base(10);
2) On the line After //One put super(10);
3) On the line After //Two put super(10);
4) On the line After //Three put super(10);
________________________________________
Question 41)
Given the following code what will be output?
public class Pass{
static int j=20;
public static void main(String argv[]){
int i=10;
Pass p = new Pass();
p.amethod(i);
System.out.println(i);
System.out.println(j);
}
public void amethod(int x){
x=x*2;
j=j*2;
}
}
1) Error: amethod parameter does not match variable
2) 20 and 40
3) 10 and 40
4) 10, and 20
________________________________________
Question 42)
What code placed after the comment //For loop would populate the elements of the array ia[] with values of the variable i.?
public class Lin{
public static void main(String argv[]){
Lin l = new Lin();
l.amethod();
}
public void amethod(){
int ia[] = new int[4];
//Start For loop
{
ia[i]=i;
System.out.println(ia[i]);
}
}
}
1) for(int i=0; i < ia.length(); i++)
2) for (int i=0; i< ia.length(); i++)
3) for(int i=1; i < 4; i++)
4) for(int i=0; i< ia.length;i++)
________________________________________
Question 43)
What will be the result when you try to compile and run the following code?
private class Base{
Base(){
int i = 100;
System.out.println(i);
}
}
public class Pri extends Base{
static int i = 200;
public static void main(String argv[]){
Pri p = new Pri();
System.out.println(i);
}
}
1) Error at compile time
2) 200
3) 100 followed by 200
4) 100
________________________________________
Question 44)
What will the following code print out?
public class Oct{
public static void main(String argv[]){
Oct o = new Oct();
o.amethod();
}
public void amethod(){
int oi= 012;
System.out.println(oi);
}
}
1)12
2)012
3)10
4)10.0
________________________________________
Question 45
What will happen when you try compiling and running this code?
public class Ref{
public static void main(String argv[]){
Ref r = new Ref();
r.amethod(r);
}
public void amethod(Ref r){
int i=99;
multi(r);
System.out.println(i);
}
public void multi(Ref r){
r.i = r.i*2;
}
}
1) Error at compile time
2) An output of 99
3) An output of 198
4) An error at runtime
________________________________________
Question 46)
You need to create a class that will store a unique object elements. You do not need to sort these elements but they must be unique.
What interface might be most suitable to meet this need?
1)Set
2)List
3)Map
4)Vector
________________________________________
Question 47)
Which of the following will successfully create an instance of the Vector class and add an element?
1) Vector v=new Vector(99);
v[1]=99;
2) Vector v=new Vector();
v.addElement(99);
3) Vector v=new Vector();
v.add(99);
4 Vector v=new Vector(100);
v.addElement("99");
________________________________________
Question 48)
You have created a simple Frame and overridden the paint method as follows
public void paint(Graphics g){
g.drawString("Dolly",50,10);
}
What will be the result when you attempt to compile and run the program?
1) The string "Dolly" will be displayed at the centre of the frame
2) An error at compilation complaining at the signature of the paint method
3) The lower part of the word Dolly will be seen at the top of the form, with the top hidden.
4) The string "Dolly" will be shown at the bottom of the form
________________________________________
Question 49)
What will be the result when you attempt to compile this program?
public class Rand{
public static void main(String argv[]){
int iRand;
iRand = Math.random();
System.out.println(iRand);
}
}
1) Compile time error referring to a cast problem
2) A random number between 1 and 10
3) A random number between 0 and 1
4) A compile time error about random being an unrecognised method
________________________________________
Question 50)
Given the following code
import java.io.*;
public class Th{
public static void main(String argv[]){
Th t = new Th();
t.amethod();
}
public void amethod(){
try{
ioCall();
}catch(IOException ioe){}
}
}
What code would be most likely for the body of the ioCall method
1) public void ioCall ()throws IOException{
DataInputStream din = new DataInputStream(System.in);
din.readChar();
}
2) public void ioCall ()throw IOException{
DataInputStream din = new DataInputStream(System.in);
din.readChar();
}
3) public void ioCall (){
DataInputStream din = new DataInputStream(System.in);
din.readChar();
}
4) public void ioCall throws IOException(){
DataInputStream din = new DataInputStream(System.in);
din.readChar();
}
________________________________________
Question 51)
What will happen when you compile and run the following code?
public class Scope{
private int i;
public static void main(String argv[]){
Scope s = new Scope();
s.amethod();
}//End of main
public static void amethod(){
System.out.println(i);
}//end of amethod
}//End of class
1) A value of 0 will be printed out
2) Nothing will be printed out
3) A compile time error
4) A compile time error complaining of the scope of the variable i
________________________________________
Question 52)
You want to lay out a set of buttons horizontally but with more space between the first button and the rest. You are going to use the GridBagLayout manager to control the way the buttons are set out. How will you modify the way the GridBagLayout acts in order to change the spacing around the first button?
1) Create an instance of the GridBagConstraints class, call the weightx() method and then pass the GridBagConstraints instance with the component to the setConstraints method of the GridBagLayout class.
2) Create an instance of the GridBagConstraints class, set the weightx field and then pass the GridBagConstraints instance with the component to the setConstraints method of the GridBagLayout class.
3) Create an instance of the GridBagLayout class, set the weightx field and then call the setConstraints method of the GridBagLayoutClass with the component as a parameter.
4) Create an instance of the GridBagLayout class, call the setWeightx() method and then pass the GridBagConstraints instance with the component to the setConstraints method of the GridBagLayout class.
________________________________________
Question 53)
Which of the following can you perform using the File class?
1) Change the current directory
2) Return the name of the parent directory
3) Delete a file
4) Find if a file contains text or binary information
________________________________________
Question 54)
Which of the following code fragments will compile without error
1)
public void paint(Graphics g){
int polyX[] = {20,150,150};
int polyY[]= {20,20,120};
g.drawPolygon(polyX, polyY,3);
}
2)
public void paint(Graphics g){
int polyX[] = {20,150,150};
int polyY[]= {20,20,120};
g.drawPolygon(polyX, polyY);
}
3)
public void paint(Graphics g){
int polyX[3] = {20,150,150};
int polyY[3]= {20,20,120};
g.drawPolygon(polyX, polyY,3);
}
4)
public void paint(Graphics g){
int polyX[] = {20,150,150};
int polyY[]= {20,20,120};
drawPolygon(polyX, polyY);
}
________________________________________
Question 55)
You are concerned about that your program may attempt to use more memory than is available. To avoid this situation you want to ensure that the Java Virtual Machine will run its garbage collection just before you start a complex routine. What can you do to be certain that garbage collection will run when you want .
1) You cannot be certain when garbage collection will run
2) Use the Runtime.gc() method to force garbage collection
3) Ensure that all the variables you require to be garbage collected are set to null
4) Use the System.gc() method to force garbage collection
________________________________________
Question 56)
You are using the GridBagLayout manager to place a series of buttons on a Frame. You want to make the size of one of the buttons bigger than the text it contains. Which of the following will allow you to do that?
1) The GridBagLayout manager does not allow you to do this
2) The setFill method of the GridBagLayout class
3) The setFill method of the GridBagConstraints class
4) The fill field of the GridBagConstraints class
________________________________________
Question 57)
Which of the following most closely describes a bitset collection?
1) A class that contains groups of unique sequences of bits
2) A method for flipping individual bits in instance of a primitive type
3) An array of boolean primitives that indicate zeros or ones
4) A collection for storing bits as on-off information, like a vector of bits
________________________________________
Question 58)
You have these files in the same directory. What will happen when you attempt to compile and run Class1.java if you have not already compiled Base.java
//Base.java
package Base;
class Base{
protected void amethod(){
System.out.println("amethod");
}//End of amethod
}//End of class base
package Class1;
//Class1.java
public class Class1 extends Base{
public static void main(String argv[]){
Base b = new Base();
b.amethod();
}//End of main
}//End of Class1
1) Compile Error: Methods in Base not found
2) Compile Error: Unable to access protected method in base class
3) Compilation followed by the output "amethod"
4)Compile error: Superclass Class1.Base of class Class1.Class1 not found
________________________________________
Question 59)
What will happen when you attempt to compile and run the following code
class Base{
private void amethod(int iBase){
System.out.println("Base.amethod");
}
}
class Over extends Base{
public static void main(String argv[]){
Over o = new Over();
int iBase=0;
o.amethod(iBase);
}
public void amethod(int iOver){
System.out.println("Over.amethod");
}
}
1) Compile time error complaining that Base.amethod is private
2) Runtime error complaining that Base.amethod is private
3) Output of Base.amethod
4) Output of Over.amethod()
________________________________________
Question 60)
You are creating an applet with a Frame that contains buttons. You are using the GridBagLayout manager and you have added Four buttons. At the moment the buttons appear in the centre of the frame from left to right. You want them to appear one on top of the other going down the screen. What is the most appropriate way to do this.
1) Set the gridy value of the GridBagConstraint class to a value increasing from 1 to 4
2) set the fill value of the GridBagConstrint class to VERTICAL
3) Set the ipady value of the GridBagConstraint class to a value increasing from 0 to 4
4) Set the fill value of the GridBagLayout class to GridBag.VERTICAL
________________________________________
Answers
________________________________________
Answer 1)
5) int i=10;
explanation:
1) float f=1.3;
Will not compile because the default type of a number with a floating point component is a double. This would compile with a cast as in
float f=(float) 1.3
2) char c="a";
Will not compile because a char (16 bit unsigned integer) must be defined with single quotes. This would compile if it were in the form
char c='a';
3) byte b=257;
Will not compile because a byte is eight bits. Take of one bit for the sign component you can define numbers between
-127 to +127
4) a boolean value can either be true of false, null is not allowed.
________________________________________
Answer 2)
1) Can't make static reference to void a method.
Because main is defined as static you need to create an instance of the class in order to call any non-static methods. Thus a typical way to do this would be.
MyClass m=new MyClass();
m.amethod();
Answer 2 is an attempt to confuse because the convention is for a main method to be in the form
String argv[]
That argv is just a convention and any acceptable identifier for a string array can be used. Answers 3 and 4 are just nonsense.
________________________________________
Answer 3)
2 and 3 will compile without error.
1 will not compile because any package declaration must come before any other code. Comments may appear anywhere.
________________________________________
Answer 4)
1) A byte is a signed 8 bit integer.
________________________________________
Answer 5)
4) Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"
Unlike C/C++ java does not start the parameter count with the program name. It does however start from zero. So in this case zero starts with good, morning would be 1 and there is no parameter 2 so an exception is raised.
________________________________________
Answer 6)
1) if
3) goto
4) while
5) case
then is not a Java keyword, though if you are from a VB background you might think it was. Goto is a reserved word in Java.
________________________________________
Answer 7)
2) variable2
3) _whatavariable
4) _3_
5) $anothervar
An identifier can begin with a letter (most common) or a dollar sign($) or an underscore(_). An identifier cannot start with anything else such as a number, a hash, # or a dash -. An identifier cannot have a dash in its body, but it may have an underscore _. Choice 4) _3_ looks strange but it is an acceptable, if unwise form for an identifier.
________________________________________
Answer 8)
4) 0
Class level variables are always initialised to default values. In the case of an int this will be 0. Method level variables are not given default values and if you attempt to use one before it has been initialised it will cause the
Error Variable i may not have been initialized
type of error.
________________________________________
Answer 9)
3 ) 2
No error will be triggered.
Like in C/C++, arrays are always referenced from 0. Java allows an array to be populated at creation time. The size of array is taken from the number of initializers. If you put a size within any of the square brackets you will get an error.
________________________________________
Answer 10)
3) 0
Arrays are always initialised when they are created. As this is an array of ints it will be initalised with zeros.
________________________________________
Answer 11)
3) Error Mine must be declared abstract
A class that contains an abstract method must itself be declared as abstract. It may however contain non abstract methods. Any class derived from an abstract class must either define all of the abstract methods or be declared abstract itself.
________________________________________
Answer 12)
3) one, two, default
Code will continue to fall through a case statement until it encounters a break.
________________________________________
Answer 13)
2) default, zero
Although it is normally placed last the default default statement does not have to be the last item as you fall through the case bock Because there is no case label found matching the expression the default label is executed and the code continues to fall through until it encounters a break.
________________________________________
Answer 14)
2,3
Example 1 will not compile because if must always test a boolean. This can catch out C/C++ programmers who expect the test to be for either 0 or not 0.
________________________________________
Answer 15)
3) No such file found, doing finally, -1
The no such file found message is to be expected, however you can get caught out if you are not aware that the finally clause is almost always executed, even if there is a return statement.
________________________________________
Answer 16)
4) code, height, width
________________________________________
Answer 17)
3) Runtime Exception
Without the cast to sub you would get a compile time error. The cast tells the compiler that you really mean to do this and the actual type of b does not get resolved until runtime. Casting down the object hierarchy as the compiler cannot be sure what has been implemented in descendent classes. Casting up is not a problem because sub classes will have the features of the base classes. This can feel counter intuitive if you are aware that with primitives casting is allowed for widening operations (ie byte to int).
________________________________________
Answer 18)
3) null
If a parameter is not available the applet will still run, but any attempt to access the parameter will return a null.
________________________________________
Answer 19)
3) Move up the hierarchy in the HTML documentation to locate methods in base
classes
The documentation created by JavaDoc is based on tags placed into the sourcecode. The convention for documentation is that methods and fields of ancestors are not duplicated in sub classes. So if you are looking for something and it does not appear to be there, you move up the class hierarchy to find it.
________________________________________
Answer 20)
3) One button occupying the entire frame saying Bye
The default layout manager for a Frame is a border layout. If directions are not given (ie North, South, East or West), any button will simply go in the centre and occupy all the space. An additional button will simply be placed over the previous button. What you would probably want in a real example is to set up a flow layout as in
setLayout(new FlowLayout()); which would.
Applets and panels have a default FlowLayout manager
________________________________________
Answer 21)
1,2
Value for i=1 Value for j=1
Value for i=2 Value for j=1
The statement continue outer causes the code to jump to the label outer and the for loop increments to the next number.
________________________________________
Answer 22)
3) An arc bounded by a box of height 50, width 50, with a top left at coordinates of 45,
90, starting at 90 degrees and traversing through 180 degrees counter clockwise.
fillArc(int x, int y, int width, int height, int startDegrees, int arcDegrees)
The fillArc function draws an arc in a box with a top left at coordinates X & Y.
If the ArcDegrees is a positive number the arc is drawn counter clockwise.
________________________________________
Answer 23)
2,4
Options 1, & 4 will not compile as they attempt to throw Exceptions not declared in the base class. Because options 2 and 4 take a parameter of type long they represent overloading not overriding and there is no such limitations on overloaded methods.
________________________________________
Answer 24)
3) System.out.println(Math.ceil(-4.7));
Options 1 and 2 will produce -5 and option 4 will not compile because the Min method requires 2 parameters.
________________________________________
Answer 25)
3) Error: Cant convert java lang Integer
The wrapper classes cannot be used like primitives.
Wrapper classes have similar names to primitives but all start with upper case letters.
Thus in this case we have int as a primitive and Integer as a wrapper. The objectives do not specifically mention the wrapper classes but don't be surprised if they come up.
________________________________________
Answer 26)
2) ic
This is a bit of a catch question. Anyone with a C/C++ background would figure out that addressing in strings starts with 0 so that 1 corresponds to i in the string Bicycle. The catch is that the second parameter returns the endcharacter minus 1. In this case it means instead of the "icy" being returned as intuition would expect it is only "ic".
________________________________________
Answer 27)
3) s.indexOf('v');
charAt returns the letter at the position rather than searching for a letter and returning the position, MID is just to confuse the Basic Programmers, indexOf(s,'v'); is how some future VB/J++ nightmare hybrid, might perform such a calculation.
________________________________________
Answer 28)
1) s3=s1 + s2;
Java does not allow operator overloading as in C++, but for the sake of convenience the + operator is overridden for strings.
________________________________________
Answer 29)
4) 7
The | is known as the Or operator, you could think of it as the either/or operator. Turning the numbers into binary gives
4=100
3=011
For each position, if either number contains a 1 the result will contain a result in that position. As every position contains a 1 the result will be
111
Which is decimal 7.
________________________________________
Answer 30)
1,2,3
public, private, static are all legal access modifiers for this inner class.
________________________________________
Answer 31)
Opening an image file requires an Image object, The Image class has no constructor that takes the name of an image file . For an application (rather than an applet) an image is created using the Toolkit class as in option 2.
2) Image image=Toolkit.getDefaultToolkit().getImage("MyPicture.jpg");
________________________________________
Answer 32)
2) setLayout(new GridLayout(2,2));
Changing the layout manager is the same for an Applet or an application. Answer 1 is wrong and implausible as a standard method is unlikely to have a name as long as setLayoutManager. Answers 3 and 4 are incorrect because changing the layout manager always requires an instance of one of the Layout Managers and these are bogus methods.
Instead of creating the anonymous instance of the Layout manager as in option 2 you can also create a named instance and pass that as a parameter. This is often what automatic code generators such as Borland/Inprise JBuilder do.
________________________________________
Answer 33)
3) The code will cause an error at compile time
The error is caused because run should have a void not an int return type.
Any class that is implements an interface must create a method to match all of the methods in the interface. The Runnable interface has one method called run that has a void return type.The sun compiler gives the error
Method redefined with different return type: int run() was defined as void run();
________________________________________
Answer 34)
2) public void update(Graphics g) {
paint(g);
}
If not overridden the update method clears the background and calls paint(); By overriding the update method, any previously drawn graphics will not be cleared. This is only a trivial way of preserving any graphics drawn. If the application is resized or the drawing area covered in some way the graphics will be cleared.
________________________________________
Answer 35)
4) Compile time error
The only operator overloading offered by java is the + sign for the String class. A char is a 16 bit integer and cannot be concatenated to a string with the + operator.
________________________________________
Answer 36)
3) if(s.equalsIgnoreCase(s2))
String comparison is case sensitive so using the equals string method will not return a match. Using the==operator just compares where memory address of the references and noCaseMatch was just something I made up to give me a fourth slightly plausible option.
________________________________________
Answer 37)
1) s.setBackground(Color.pink);
For speakers of the more British spelt English note that there is no letter u in Color. Also the constants for colors are in lower case.
________________________________________
Answer 38)
4) The File class does not support directly changing the current directory.
This seems rather surprising to me, as changing the current directory is a very common requirement. You may be able to get around this limitation by creating a new instance of the File class passing the new directory to the constructor as the path name.
________________________________________
Answer 39)
1)With a fixed font you will see 5 characters, with a proportional it will depend on the width of the characters
With a proportional font the letter w will occupy more space than the letter i. So if you have all wide characters you may have to scroll to the right to see the entire text of a TextField.
________________________________________
Answer 40)
3) On the line After //Two put super(10);
Constructors can only be invoked from within constructors.
________________________________________
Answer 41)
3) 10 and 40
when a parameter is passed to a method the method receives a copy of the value. The method can modify its value without affecting the original copy. Thus in this example when the value is printed out the method has not changed the value.
________________________________________
Answer 42)
4) for(int i=0; i< ia.length;i++)
Although you could control the looping with a literal number as with the number 4 used in sample 3, it is better practice to use the length property of an array. This provides against bugs that might result if the size of the array changes. This question also checks that you know that arrays starts from zero and not One.
________________________________________
Answer 43)
1) Error at compile time
This is a slightly sneaky one as it looks like a question about constructors, but it is attempting to test knowledge of the use of the private modifier. A top level class cannot be defined as private. If you didn't notice the modifier private, remember in the exam to be real careful to read every part of the question.
________________________________________
Answer 44)
3)10
The name of the class might give you a clue with this question, Oct for Octal. Prefixing a number with a zero indicates that it is in Octal format. Thus when printed out it gets converted to base ten. 012 in octal means the first column from the right has a value of 2 and the next along has a value of one times eight. In decimal that adds up to 10.
________________________________________
Answer 45)
1) Error at compile time
The variable i is created at the level of amethod and will not be available inside the method multi.
________________________________________
Answer 46)
1) Set
The Set interface ensures that its elements are unique, but does not order the elements. In reality you probably wouldn't create your own class using the Set interface. You would be more likely to use one of the JDK classes that use the Set interface such as ArraySet.
________________________________________
Answer 47)
4) Vector v=new Vector(100);
v.addElement("99")
A vector can only store objects not primitives. The parameter "99" for the addElement method pases a string object to the Vector. Option 1) creates a vector OK but then uses array syntax to attempt to assign a primitive. Option 2 also creates a vector then uses correct Vector syntax but falls over when the parameter is a primitive instead of an object. Option 3 compounds the errors by using the fictitious add method.
________________________________________
Answer 48)
3) The lower part of the word Dolly will be seen at the top of the form
The Second parameter to the drawstring method indicates where the baseline of the string will be placed. Thus the 3rd parameter of 10 indicates the Y coordinate to be 10 pixels from the top of the Frame. This will result in just the bottom of the string Dolly showing up or possibly only the descending part of the letter y.
________________________________________
Answer 49)
1) Compile time error referring to a cast problem
This is a bit of a sneaky one as the Math.random method returns a pseudo random number between 0 and 1, and thus option 3 is a plausible answer. However the number returned is a double and so the compiler will complain that a cast is needed to convert a double to an int.
________________________________________
Answer 50)
1) public void ioCall ()throws IOException{
DataInputStream din = new DataInputStream(System.in);
din.readChar();
}
If a method might throw an exception it must either be caught within the method with a try/catch block, or the method must indicate the exception to any calling method by use of the throws statement in its declaration. Without this, an error will occur at compile time.
________________________________________
Answer 51)
3) A compile time error
Because only one instance of a static method exists not matter how many instance of the class exists it cannot access any non static variables. The JVM cannot know which instance of the variable to access. Thus you will get an error saying something like
Can't make a static reference to a non static variable
________________________________________
Answer 52)
2) Create an instance of the GridBagConstraints class, set the weightx field and then pass the GridBagConstraints instance with the component to the setConstraints method of the GridBagLayout class.
The Key to using the GridBagLayout manager is the GridBagConstraint class. This class is not consistent with the general naming conventions in the java API as you would expect that weightx would be set with a method, whereas it is a simple field (variable).
________________________________________
Answer 53)
2) Return the name of the parent directory
3) Delete a file
It is surprising that you can't change the current directory. If you need to do this, the best way seems to be to create a new instance of the File class and pass the new directory to the constructor. It is not so surprising that you can't tell if a file contains text or binary information.
________________________________________
Answer 54)
1)
public void paint(Graphics g){
int polyX[] = {20,150,150};
int polyY[]= {20,20,120};
g.drawPolygon(polyX, polyY,3);
}
Drawpolygon takes three parameters, the first two are arrays of the X,Y coordinates and the final is n integer specifying the number of vertices (whatever they are).
________________________________________
Answer 55)
1) You cannot be certain when garbage collection will run
Although there is a Runtime.gc(), this only suggests that the Java Virtual Machine does its garbage collection. You can never be certain when the garbage collector will run. Roberts and Heller is more specific abou this than Boone. This uncertainty can cause consternation for C++ programmers who wish to run finalize methods with the same intent as they use destructor methods.
________________________________________
Answer 56)
4) The fill field of the GridBagConstraints class
Unlike the GridLayout manager you can set the individual size of a control such as a button using the GridBagLayout manager. A little background knowledge would indicate that it should be controlled by a setSomethingOrOther method, but it isn't.
________________________________________
Answer 57)
4) A collection for storing bits as on-off information, like a vector of bits
This is the description given to a bitset in Bruce Eckels "Thinking in Java" book. The reference to unique sequence of bits was an attempt to mislead because of the use of the word Set in the name bitset. Normally something called a set implies uniqueness of the members, but not in this context.
________________________________________
Answer 58)
4)Compile error: Superclass Class1.Base of class Class1.Class1 not found
Using the package statement has an effect similar to placing a source file into a different directory. Because the files are in different packages they cannot see each other. The stuff about File1 not having been compiled was just to mislead, java has the equivalent of an "automake", whereby if it was not for the package statements the other file would have been automatically compiled.
________________________________________
Answer 59)
4) Output of Over.amethod()
The names of parameters to an overridden method is not important.
________________________________________
Answer 60)
1) Set the gridy value of the GridBagConstraint class to a value increasing from 1 to 4
Answer 4 is fairly obviously bogus as it is the GridBagConstraint class that does most of the magic in laying out components under the GridBagLayout manager. The fill value of the GridBagConstraint class controls the behavior inside its virtual cell and the ipady field controls the internal padding around a component.
STRING HANDLING
1. Which package does define String and StringBuffer classes?
Ans : java.lang package.
2. Which method can be used to obtain the length of the String?
Ans : length( ) method.
3. How do you concatenate Strings?
Ans : By using " + " operator.
4. Which method can be used to compare two strings for equality?
Ans : equals( ) method.
5. Which method can be used to perform a comparison between strings that ignores case differences?
Ans : equalsIgnoreCase( ) method.
6. What is the use of valueOf( ) method?
Ans : valueOf( ) method converts data from its internal format into a human-readable form.
7. What are the uses of toLowerCase( ) and toUpperCase( ) methods?
Ans : The method toLowerCase( ) converts all the characters in a string from uppercase to
lowercase.
The method toUpperCase( ) converts all the characters in a string from lowercase to
uppercase.
8. Which method can be used to find out the total allocated capacity of a StrinBuffer?
Ans : capacity( ) method.
9. Which method can be used to set the length of the buffer within a StringBuffer object?
Ans : setLength( ).
10. What is the difference between String and StringBuffer?
Ans : String objects are constants, whereas StringBuffer objects are not.
String class supports constant strings, whereas StringBuffer class supports growable, modifiable strings.
11. What are wrapper classes?
Ans : Wrapper classes are classes that allow primitive types to be accessed as objects.
12. Which of the following is not a wrapper class?
a. String
b. Integer
c. Boolean
d. Character
Ans : a.
1. What is the output of the following program?
public class Question {
public static void main(String args[]) {
String s1 = "abc";
String s2 = "def";
String s3 = s1.concat(s2.toUpperCase( ) );
System.out.println(s1+s2+s3);
}
}
a. abcdefabcdef
b. abcabcDEFDEF
c. abcdefabcDEF
d. None of the above
ANS : c.
1. Which of the following methods are methods of the String class?
a. delete( )
b. append( )
c. reverse( )
d. replace( )
Ans : d.
1. Which of the following methods cause the String object referenced by s to be changed?
a. s.concat( )
b. s.toUpperCase( )
c. s.replace( )
d. s.valueOf( )
Ans : a and b.
1. String is a wrapper class?
a. True
b. False
Ans : b.
17) If you run the code below, what gets printed out?
String s=new String("Bicycle");
int iBegin=1;
char iEnd=3;
System.out.println(s.substring(iBegin,iEnd));
a. Bic
b. ic
c) icy
d) error: no method matching substring(int,char)
Ans : b.
18) Given the following declarations
String s1=new String("Hello")
String s2=new String("there");
String s3=new String();
Which of the following are legal operations?
a. s3=s1 + s2;
b. s3=s1 - s2;
c) s3=s1 & s2
d) s3=s1 && s2
Ans : a.
19) Which of the following statements are true?
a. The String class is implemented as a char array, elements are addressed using the stringname[] convention
b) Strings are a primitive type in Java that overloads the + operator for concatenation
c) Strings are a primitive type in Java and the StringBuffer is used as the matching wrapper type
d) The size of a string can be retrieved using the length property.
Ans : b.
EXPLORING JAVA.LANG
1. java.lang package is automatically imported into all programs.
a. True
b. False
Ans : a
1. What are the interfaces defined by java.lang?
Ans : Cloneable, Comparable and Runnable.
2. What are the constants defined by both Flaot and Double classes?
Ans : MAX_VALUE,
MIN_VALUE,
NaN,
POSITIVE_INFINITY,
NEGATIVE_INFINITY and
TYPE.
3. What are the constants defined by Byte, Short, Integer and Long?
Ans : MAX_VALUE,
MIN_VALUE and
TYPE.
4. What are the constants defined by both Float and Double classes?
Ans : MAX_RADIX,
MIN_RADIX,
MAX_VALUE,
MIN_VALUE and
TYPE.
5. What is the purpose of the Runtime class?
Ans : The purpose of the Runtime class is to provide access to the Java runtime system.
6. What is the purpose of the System class?
Ans : The purpose of the System class is to provide access to system resources.
7. Which class is extended by all other classes?
Ans : Object class is extended by all other classes.
8. Which class can be used to obtain design information about an object?
Ans : The Class class can be used to obtain information about an object’s design.
9. Which method is used to calculate the absolute value of a number?
Ans : abs( ) method.
10. What are E and PI?
Ans : E is the base of the natural logarithm and PI is the mathematical value pi.
11. Which of the following classes is used to perform basic console I/O?
a. System
b. SecurityManager
c. Math
d. Runtime
Ans : a.
1. Which of the following are true?
a. The Class class is the superclass of the Object class.
b. The Object class is final.
c. The Class class can be used to load other classes.
d. The ClassLoader class can be used to load other classes.
Ans : c and d.
1. Which of the following methods are methods of the Math class?
a. absolute( )
b. log( )
c. cosine( )
d. sine( )
Ans : b.
1. Which of the following are true about the Error and Exception classes?
a. Both classes extend Throwable.
b. The Error class is final and the Exception class is not.
c. The Exception class is final and the Error is not.
d. Both classes implement Throwable.
Ans : a.
1. Which of the following are true?
a. The Void class extends the Class class.
b. The Float class extends the Double class.
c. The System class extends the Runtime class.
d. The Integer class extends the Number class.
Ans : d.
17) Which of the following will output -4.0
a. System.out.println(Math.floor(-4.7));
b. System.out.println(Math.round(-4.7));
c. System.out.println(Math.ceil(-4.7));
d) System.out.println(Math.Min(-4.7));
Ans : c.
18) Which of the following are valid statements
a) public class MyCalc extends Math
b) Math.max(s);
c) Math.round(9.99,1);
d) Math.mod(4,10);
e) None of the above.
Ans : e.
19) What will happen if you attempt to compile and run the following code?
Integer ten=new Integer(10);
Long nine=new Long (9);
System.out.println(ten + nine);
int i=1;
System.out.println(i + ten);
a. 19 followed by 20
b. 19 followed by 11
c. Error: Can't convert java lang Integer
d) 10 followed by 1
Ans : c.
INPUT / OUTPUT : EXPLORING JAVA.IO
1. What is meant by Stream and what are the types of Streams and classes of the Streams?
Ans : A Stream is an abstraction that either produces or consumes information.
There are two types of Streams. They are:
Byte Streams : Byte Streams provide a convenient means for handling input and output of bytes.
Character Streams : Character Streams provide a convenient means for handling input and output of characters.
Byte Stream classes : Byte Streams are defined by using two abstract classes. They are:InputStream and OutputStream.
Character Stream classes : Character Streams are defined by using two abstract classes. They are : Reader and Writer.
2. Which of the following statements are true?
a. UTF characters are all 8-bits.
b. UTF characters are all 16-bits.
c. UTF characters are all 24-bits.
d. Unicode characters are all 16-bits.
e. Bytecode characters are all 16-bits.
Ans : d.
1. Which of the following statements are true?
a. When you construct an instance of File, if you do not use the filenaming semantics of the local machine, the constructor will throw an IOException.
b. When you construct an instance of File, if the corresponding file does not exist on the local file system, one will be created.
c. When an instance of File is garbage collected, the corresponding file on the local file system is deleted.
d. None of the above.
Ans : a,b and c.
1. The File class contains a method that changes the current working directory.
a. True
b. False
Ans : b.
1. It is possible to use the File class to list the contents of the current working directory.
a. True
b. False
Ans : a.
1. Readers have methods that can read and return floats and doubles.
a. True
b. False
Ans : b.
1. You execute the code below in an empty directory. What is the result?
File f1 = new File("dirname");
File f2 = new File(f1, "filename");
a. A new directory called dirname is created in the current working directory.
b. A new directory called dirname is created in the current working directory. A new file called filename is created in directory dirname.
c. A new directory called dirname and a new file called filename are created, both in the current working directory.
d. A new file called filename is created in the current working directory.
e. No directory is created, and no file is created.
Ans : e.
1. What is the difference between the Reader/Writer class hierarchy and the
InputStream/OutputStream class hierarchy?
Ans : The Reader/Writer class hierarchy is character-oriented and the InputStream/OutputStream class hierarchy is byte-oriented.
2. What is an I/O filter?
Ans : An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.
3. What is the purpose of the File class?
Ans : The File class is used to create objects that provide access to the files and directories of a local file system.
4. What interface must an object implement before it can be written to a stream as an object?
Ans : An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.
5. What is the difference between the File and RandomAccessFile classes?
Ans : The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.
6. What class allows you to read objects directly from a stream?
Ans : The ObjectInputStream class supports the reading of objects from input streams.
7. What value does read( ) return when it has reached the end of a file?
Ans : The read( ) method returns – 1 when it has reached the end of a file.
8. What value does readLine( ) return when it has reached the end of a file?
Ans : The readLine( ) method returns null when it has reached the end of a file.
9. How many bits are used to represent Unicode, ASCII, UTF-16 and UTF-8 characters?
Ans : Unicode requires 16-bits and ASCII requires 8-bits. Although the ASCII character set uses only 1-bits, it is usually represented as 8-bits. UTF-8 represents characters using 8, 16 and 18-bit patterns. UTF-16 uses 16-bit and larger bit patterns.
10. Which of the following are true?
a. The InputStream and OutputStream classes are byte-oriented.
b. The ObjectInputStream and ObjectOutputStream do not support serialized object input and output.
c. The Reader and Writer classes are character-oriented.
d. The Reader and Writer classes are the preferred solution to serialized object output.
Ans : a and c.
1. Which of the following are true about I/O filters?
a. Filters are supported on input, but not on output.
b. Filters are supported by the InputStream/OutputStream class hierarchy, but not by the Reader/Writer class hierarchy.
c. Filters read from one stream and write to another.
d. A filter may alter data that is read from one stream and written to another.
Ans : c and d.
1. Which of the following are true?
a. Any Unicode character is represented using 16-bits.
b. 7-bits are needed to represent any ASCII character.
c. UTF-8 characters are represented using only 8-bits.
d. UTF-16 characters are represented using only 16-bits.
Ans : a and b.
1. Which of the following are true?
a. The Serializable interface is used to identify objects that may be written to an output stream.
b. The Externalizable interface is implemented by classes that control the way in which their objects are serialized.
c. The Serializable interface extends the Externalizable interface.
d. The Externalizable interface extends the Serializable interface.
Ans : a, b and d.
1. Which of the following are true about the File class?
a. A File object can be used to change the current working directory.
b. A File object can be used to access the files in the current directory.
c. When a File object is created, a corresponding directory or file is created in the local file system.
d. File objects are used to access files and directories on the local file system.
e. File objects can be garbage collected.
f. When a File object is garbage collected, the corresponding file or directory is deleted.
Ans : b, d and e.
1. How do you create a Reader object from an InputStream object?
a. Use the static createReader( ) method of InputStream class.
b. Use the static createReader( ) method of Reader class.
c. Create an InputStreamReader object, passing the InputStream object as an argument to the InputStreamReader constructor.
d. Create an OutputStreamReader object, passing the InputStream object as an argument to the OutputStreamReader constructor.
Ans : c.
1. Which of the following are true?
a. Writer classes can be used to write characters to output streams using different character encodings.
b. Writer classes can be used to write Unicode characters to output streams.
c. Writer classes have methods that support the writing of the values of any Java primitive type to output streams.
d. Writer classes have methods that support the writing of objects to output streams.
Ans : a and b.
1. The isFile( ) method returns a boolean value depending on whether the file object is a file or a directory.
a. True.
b. False.
Ans : a.
1. Reading or writing can be done even after closing the input/output source.
a. True.
b. False.
Ans : b.
1. The ________ method helps in clearing the buffer.
Ans : flush( ).
2. The System.err method is used to print error message.
a. True.
b. False.
Ans : a.
1. What is meant by StreamTokenizer?
Ans : StreamTokenizer breaks up InputStream into tokens that are delimited by sets of characters.
It has the constructor : StreamTokenizer(Reader inStream).
Here inStream must be some form of Reader.
2. What is Serialization and deserialization?
Ans : Serialization is the process of writing the state of an object to a byte stream.
Deserialization is the process of restoring these objects.
30) Which of the following can you perform using the File class?
a) Change the current directory
b) Return the name of the parent directory
c) Delete a file
d) Find if a file contains text or binary information
Ans : b and c.
31)How can you change the current working directory using an instance of the File class called FileName?
a. FileName.chdir("DirName").
b. FileName.cd("DirName").
c. FileName.cwd("DirName").
d. The File class does not support directly changing the current directory.
Ans : d.
APPLETS
1. What is an Applet? Should applets have constructors?
Ans : Applet is a dynamic and interactive program that runs inside a Web page
displayed by a Java capable browser. We don’t have the concept of Constructors in Applets.
2. How do we read number information from my applet’s parameters, given that Applet’s getParameter() method returns a string?
Ans : Use the parseInt() method in the Integer Class, the Float(String) constructor in the
Class Float, or the Double(String) constructor in the class Double.
3. How can I arrange for different applets on a web page to communicate with each other?
Ans : Name your applets inside the Applet tag and invoke AppletContext’s getApplet()
method in your applet code to obtain references to the other applets on the page.
4. How do I select a URL from my Applet and send the browser to that page?
Ans : Ask the applet for its applet context and invoke showDocument() on that context object.
Eg. URL targetURL;
String URLString
AppletContext context = getAppletContext();
try{
targetUR L = new URL(URLString);
} catch (Malformed URLException e){
// Code for recover from the exception
}
context. showDocument (targetURL);
5. Can applets on different pages communicate with each other?
Ans : No. Not Directly. The applets will exchange the information at one meeting place
either on the local file system or at remote system.
6. How do Applets differ from Applications?
Ans : Appln: Stand Alone
Applet: Needs no explicit installation on local m/c.
Appln: Execution starts with main() method.
Applet: Execution starts with init() method.
Appln: May or may not be a GUI
Applet: Must run within a GUI (Using AWT)
7. How do I determine the width and height of my application?
Ans : Use the getSize() method, which the Applet class inherits from the Component
class in the Java.awt package. The getSize() method returns the size of the applet as
a Dimension object, from which you extract separate width, height fields.
Eg. Dimension dim = getSize ();
int appletwidth = dim.width ();
8) What is AppletStub Interface?
Ans : The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface.
9. It is essential to have both the .java file and the .html file of an applet in the same
directory.
a. True.
b. False.
Ans : b.
9. The tag contains two attributes namely _________ and _______.
Ans : Name , value.
10. Passing values to parameters is done in the _________ file of an applet.
Ans : .html.
12) What tags are mandatory when creating HTML to display an applet
a. name, height, width
b. code, name
c. codebase, height, width
d) code, height, width
Ans : d.
13. Applet’s getParameter( ) method can be used to get parameter values.
a. True.
b. False.
Ans : a.
13. What are the Applet’s Life Cycle methods? Explain them?
Ans : init( ) method - Can be called when an applet is first loaded.
start( ) method - Can be called each time an applet is started.
paint( ) method - Can be called when the applet is minimized or refreshed.
stop( ) method - Can be called when the browser moves off the applet’s page.
destroy( ) method - Can be called when the browser is finished with the applet.
14. What are the Applet’s information methods?
Ans : getAppletInfo( ) method : Returns a string describing the applet, its author ,copy
right information, etc.
getParameterInfo( ) method : Returns an array of string describing the applet’s parameters.
15. All Applets are subclasses of Applet.
a. True.
b. False.
Ans : a.
13. All Applets must import java.applet and java.awt.
a. True.
b. False.
Ans : a.
13. What are the steps involved in Applet development?
Ans : a) Edit a Java source file,
b) Compile your program and
c) Execute the appletviewer, specifying the name of your applet’s source file.
14. Applets are executed by the console based Java run-time interpreter.
a. True.
b. False.
Ans : b.
13. Which classes and interfaces does Applet class consist?
Ans : Applet class consists of a single class, the Applet class and three interfaces: AppletContext,
AppletStub and AudioClip.
14. What is the sequence for calling the methods by AWT for applets?
Ans : When an applet begins, the AWT calls the following methods, in this sequence.
1. init( )
2. start( )
3. paint( )
When an applet is terminated, the following sequence of method cals takes place :
1. stop( )
2. destroy( )
13. Which method is used to output a string to an applet?
Ans : drawString ( ) method.
14. Every color is created from an RGB value.
a. True.
b. False
Ans : a.
EVENT HANDLING
1. The event delegation model, introduced in release 1.1 of the JDK, is fully compatible with the
1. event model.
a. True
b. False
Ans : b.
1. A component subclass that has executed enableEvents( ) to enable processing of a certain kind of event cannot also use an adapter as a listener for the same kind of event.
a. True
b. False
Ans : b.
1. What is the highest-level event class of the event-delegation model?
Ans : The java.util.eventObject class is the highest-level class in the event-delegation hierarchy.
2. What interface is extended by AWT event listeners?
Ans : All AWT event listeners extend the java.util.EventListener interface.
3. What class is the top of the AWT event hierarchy?
Ans : The java.awt.AWTEvent class is the highest-level class in the AWT event class hierarchy.
4. What event results from the clicking of a button?
Ans : The ActionEvent event is generated as the result of the clicking of a button.
5. What is the relationship between an event-listener interface and an event-adapter class?
Ans : An event-listener interface defines the methods that must be implemented by an event
handler for a particular kind of event.
An event adapter provides a default implementation of an event-listener interface.
6. In which package are most of the AWT events that support the event-delegation model defined?
Ans : Most of the AWT–related events of the event-delegation model are defined in the
java.awt.event package. The AWTEvent class is defined in the java.awt package.
7. What is the advantage of the event-delegation model over the earlier event-inheritance model?
Ans : The event-delegation has two advantages over the event-inheritance model. They are :
1. It enables event handling by objects other than the ones that generate the events. This
allows a clean separation between a component’s design and its use.
2. It performs much better in applications where many events are generated. This
performance improvement is due to the fact that the event-delegation model does not
have to repeatedly process unhandled events, as is the case of the event-inheritance
model.
1. What is the purpose of the enableEvents( ) method?
Ans :The enableEvents( ) method is used to enable an event for a particular object.
2. Which of the following are true?
a. The event-inheritance model has replaced the event-delegation model.
b. The event-inheritance model is more efficient than the event-delegation model.
c. The event-delegation model uses event listeners to define the methods of event-handling classes.
d. The event-delegation model uses the handleEvent( ) method to support event handling.
Ans : c.
1. Which of the following is the highest class in the event-delegation model?
a. java.util.EventListener
b. java.util.EventObject
c. java.awt.AWTEvent
d. java.awt.event.AWTEvent
Ans : b.
1. When two or more objects are added as listeners for the same event, which listener is first invoked to handle the event?
a. The first object that was added as listener.
b. The last object that was added as listener.
c. There is no way to determine which listener will be invoked first.
d. It is impossible to have more than one listener for a given event.
Ans : c.
1. Which of the following components generate action events?
a. Buttons
b. Labels
c. Check boxes
d. Windows
Ans : a.
1. Which of the following are true?
a. A TextField object may generate an ActionEvent.
b. A TextArea object may generate an ActionEvent.
c. A Button object may generate an ActionEvent.
d. A MenuItem object may generate an ActionEvent.
Ans : a,c and d.
1. Which of the following are true?
a. The MouseListener interface defines methods for handling mouse clicks.
b. The MouseMotionListener interface defines methods for handling mouse clicks.
c. The MouseClickListener interface defines methods for handling mouse clicks.
d. The ActionListener interface defines methods for handling the clicking of a button.
Ans : a and d.
1. Suppose that you want to have an object eh handle the TextEvent of a TextArea object t. How should you add eh as the event handler for t?
a. t.addTextListener(eh);
b. eh.addTextListener(t);
c. addTextListener(eh.t);
d. addTextListener(t,eh);
Ans : a.
1. What is the preferred way to handle an object’s events in Java 2?
a. Override the object’s handleEvent( ) method.
b. Add one or more event listeners to handle the events.
c. Have the object override its processEvent( ) methods.
d. Have the object override its dispatchEvent( ) methods.
Ans : b.
1. Which of the following are true?
a. A component may handle its own events by adding itself as an event listener.
b. A component may handle its own events by overriding its event-dispatching method.
c. A component may not handle oits own events.
d. A component may handle its own events only if it implements the handleEvent( ) method.
Ans : a and b.
1. How many types of events are provided by AWT? Explain them?
Ans : The AWT provides two types of events. They are :
1. Low-level event : A low-level event is the one that represents a low-level input or
window-system occurrence on a visual component on the screen.
2. Semantic event : Semantic event is defined at a higher-level to encapsulate the
semantics of a user interface component’s model.
1. A __________ is an object that originates or "fire" events.
Ans : source.
2. The event listener corresponding to handling keyboard events is the _________ .
Ans : KeyListener.
3. What are the types of mouse event listeners?
Ans : MouseListener and MouseMotionListener.
24) Which of the following are correct event handling methods
a) mousePressed(MouseEvent e){}
b) MousePressed(MouseClick e){}
c) functionKey(KeyPress k){}
d) componentAdded(ContainerEvent e){}
Ans : a and d.
25) Which of the following are true?
a) A component may have only one event listener attached at a time
b) An event listener may be removed from a component
c) The ActionListener interface has no corresponding Adapter class
d) The processing of an event listener requires a try/catch block
Ans : b and c.
AWT : WINDOWS, GRAPHICS AND FONTS
1. How would you set the color of a graphics context called g to cyan?
a. g.setColor(Color.cyan);
b. g.setCurrentColor(cyan);
c. g.setColor("Color.cyan");
d. g.setColor("cyan’);
e. g.setColor(new Color(cyan));
Ans : a.
1. The code below draws a line. What color is the line?
g.setColor(Color.red.green.yellow.red.cyan);
g.drawLine(0, 0, 100,100);
a. Red
b. Green
c. Yellow
d. Cyan
e. Black
Ans : d.
1. What does the following code draw?
g.setColor(Color.black);
g.drawLine(10, 10, 10, 50);
g.setColor(Color.RED);
g.drawRect(100, 100, 150, 150);
a. A red vertical line that is 40 pixels long and a red square with sides of 150 pixels
b. A black vertical line that is 40 pixels long and a red square with sides of 150 pixels
c. A black vertical line that is 50 pixels long and a red square with sides of 150 pixels
d. A red vertical line that is 50 pixels long and a red square with sides of 150 pixels
e. A black vertical line that is 40 pixels long and a red square with sides of 100 pixel
Ans : b.
1. Which of the statements below are true?
a. A polyline is always filled.
b) A polyline can not be filled.
c) A polygon is always filled.
d) A polygon is always closed
e) A polygon may be filled or not filled
Ans : b, d and e.
1. What code would you use to construct a 24-point bold serif font?
a. new Font(Font.SERIF, 24,Font.BOLD);
b. new Font("SERIF", 24, BOLD");
c. new Font("BOLD ", 24,Font.SERIF);
d. new Font("SERIF", Font.BOLD,24);
e. new Font(Font.SERIF, "BOLD", 24);
Ans : d.
1. What does the following paint( ) method draw?
Public void paint(Graphics g) {
g.drawString("question #6",10,0);
}
a. The string "question #6", with its top-left corner at 10,0
b. A little squiggle coming down from the top of the component, a little way in from the left edge
Ans : b.
1. What does the following paint( ) method draw?
Public void paint(Graphics g) {
g.drawString("question #6",10,0);
}
a. A circle at (100, 100) with radius of 44
b. A circle at (100, 44) with radius of 100
c. A circle at (100, 44) with radius of 44
d. The code does not compile
Ans : d.
8)What is relationship between the Canvas class and the Graphics class?
Ans : A Canvas object provides access to a Graphics object via its paint( ) method.
1. What are the Component subclasses that support painting.
Ans : The Canvas, Frame, Panel and Applet classes support painting.
2. What is the difference between the paint( ) and repaint( ) method?
Ans : The paint( ) method supports painting via a Graphics object. The repaint( ) method is used
to cause paint( ) to be invoked by the AWT painting method.
3. What is the difference between the Font and FontMetrics classes?
Ans : The FontMetrics class is used to define implementation-specific properties, such as ascent
and descent, of a Font object.
4. Which of the following are passed as an argument to the paint( ) method?
a. A Canvas object
b. A Graphics object
c. An Image object
d. A paint object
Ans : b.
1. Which of the following methods are invoked by the AWT to support paint and repaint operations?
a. paint( )
b. repaint( )
c. draw( )
d. redraw( )
Ans : a.
1. Which of the following classes have a paint( ) method?
a. Canvas
b. Image
c. Frame
d. Graphics
Ans : a and c.
1. Which of the following are methods of the Graphics class?
a. drawRect( )
b. drawImage( )
c. drawPoint( )
d. drawString( )
Ans : a, b and d.
1. Which Font attributes are available through the FontMetrics class?
a. ascent
b. leading
c. case
d. height
Ans : a, b and d.
1. Which of the following are true?
a. The AWT automatically causes a window to be repainted when a portion of a window has been minimized and then maximized.
b. The AWT automatically causes a window to be repainted when a portion of a window has been covered and then uncovered.
c. The AWT automatically causes a window to be repainted when application data is changed.
d. The AWT does not support repainting operations.
Ans : a and b.
1. Which method is used to size a graphics object to fit the current size of the window?
Ans : getSize( ) method.
2. What are the methods to be used to set foreground and background colors?
Ans : setForeground( ) and setBackground( ) methods.
19) You have created a simple Frame and overridden the paint method as follows
public void paint(Graphics g){
g.drawString("Dolly",50,10);
}
What will be the result when you attempt to compile and run the program?
a. The string "Dolly" will be displayed at the centre of the frame
b) An error at compilation complaining at the signature of the paint method
c) The lower part of the word Dolly will be seen at the top of the form, with the top hidden.
d) The string "Dolly" will be shown at the bottom of the form
Ans : c.
20) Where g is a graphics instance what will the following code draw on the screen.
g.fillArc(45,90,50,50,90,180);
a) An arc bounded by a box of height 45, width 90 with a centre point of 50,50, starting
at an angle of 90 degrees traversing through 180 degrees counter clockwise.
b) An arc bounded by a box of height 50, width 50, with a centre point of 45,90 starting
at an angle of 90 degrees traversing through 180 degrees clockwise.
c) An arc bounded by a box of height 50, width 50, with a top left at coordinates of 45,
90, starting at 90 degrees and traversing through 180 degrees counter clockwise.
d) An arc starting at 45 degrees, traversing through 90 degrees clockwise bounded by a
box of height 50, width 50 with a centre point of 90, 180.
Ans : c.
21) Given the following code
import java.awt.*;
public class SetF extends Frame{
public static void main(String argv[]){
SetF s = new SetF();
s.setSize(300,200);
s.setVisible(true);
}
}
How could you set the frame surface color to pink
a)s.setBackground(Color.pink);
b)s.setColor(PINK);
c)s.Background(pink);
d)s.color=Color.pink
Ans : a.
AWT: CONTROLS, LAYOUT MANAGERS AND MENUS
1. What is meant by Controls and what are different types of controls?
Ans : Controls are componenets that allow a user to interact with your application.
The AWT supports the following types of controls:
o Labels
o Push buttons
o Check boxes
o Choice lists
o Lists
o Scroll bars
o Text components
These controls are subclasses of Component.
1. You want to construct a text area that is 80 character-widths wide and 10 character-heights tall. What code do you use?
a. new TextArea(80, 10)
b. new TextArea(10, 80)
Ans: b.
1. A text field has a variable-width font. It is constructed by calling new
TextField("iiiii"). What happens if you change the contents of the text field to
"wwwww"? (Bear in mind that is one of the narrowest characters, and w is one of the widest.)
a. The text field becomes wider.
b. The text field becomes narrower.
c. The text field stays the same width; to see the entire contents you will have to scroll by using the  and  keys.
d. The text field stays the same width; to see the entire contents you will have to scroll by using the text field’s horizontal scroll bar.
Ans : c.
1. The CheckboxGroup class is a subclass of the Component class.
a. True
b. False
Ans : b.
5) What are the immediate super classes of the following classes?
a. a) Container class
b. b) MenuComponent class
c. c) Dialog class
d. d) Applet class
e. e) Menu class
Ans : a) Container - Component
b) MenuComponent - Object
c) Dialog - Window
d) Applet - Panel
e) Menu - MenuItem
6) What are the SubClass of Textcomponent Class?
Ans : TextField and TextArea
7) Which method of the component class is used to set the position and the size of a component?
Ans : setBounds()
8) Which TextComponent method is used to set a TextComponent to the read-only state?
Ans : setEditable()
9) How can the Checkbox class be used to create a radio button?
Ans : By associating Checkbox objects with a CheckboxGroup.
10) What Checkbox method allows you to tell if a Checkbox is checked?
Ans : getState()
11) Which Component method is used to access a component's immediate Container?
a. getVisible()
b. getImmediate
c. getParent()
d. getContainer
Ans : c.
12) What methods are used to get and set the text label displayed by a Button object?
Ans : getLabel( ) and setLabel( )
13) What is the difference between a Choice and a List?
Ans : A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice.
A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.
14) Which Container method is used to cause a container to be laid out and redisplayed?
Ans : validate( )
15) What is the difference between a Scollbar and a Scrollpane?
Ans : A Scrollbar is a Component, but not a Container.
A Scrollpane is a Container and handles its own events and performs its own
scrolling.
16) Which Component subclass is used for drawing and painting?
Ans : Canvas.
17) Which of the following are direct or indirect subclasses of Component?
a. Button
b. Label
c. CheckboxMenuItem
d. Toolbar
e. Frame
Ans : a, b and e.
18) Which of the following are direct or indirect subclasses of Container?
a. Frame
b. TextArea
c. MenuBar
d. FileDialog
e. Applet
Ans : a,d and e.
19) Which method is used to set the text of a Label object?
a. setText( )
b. setLabel( )
c. setTextLabel( )
d. setLabelText( )
Ans : a.
20) Which constructor creates a TextArea with 10 rows and 20 columns?
a. new TextArea(10, 20)
b. new TextArea(20, 10)
c. new TextArea(new Rows(10), new columns(20))
d. new TextArea(200)
Ans : a.
(Usage is TextArea(rows, columns)
21) Which of the following creates a List with 5 visible items and multiple selection enabled?
a. new List(5, true)
b. new List(true, 5)
c. new List(5, false)
d. new List(false,5)
Ans : a.
[Usage is List(rows, multipleMode)]
22) Which are true about the Container class?
a. The validate( ) method is used to cause a Container to be laid out and redisplayed.
b. The add( ) method is used to add a Component to a Container.
c. The getBorder( ) method returns information about a Container’s insets.
d. The getComponent( ) method is used to access a Component that is contained in a Container.
Ans : a, b and d.
23) Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame’s font is set to 12-point TimesRoman, the Panel’s font is set to 10-point TimesRoman, and the Button’s font is not set, what font will be used to dispaly the Button’s label?
a. 12-point TimesRoman
b. 11-point TimesRoman
c. 10-point TimesRoman
d. 9-point TimesRoman
Ans : c.
1. A Frame’s background color is set to Color.Yellow, and a Button’s background color is to Color.Blue. Suppose the Button is added to a Panel, which is added to the Frame. What background color will be used with the Panel?
a. Colr.Yellow
b. Color.Blue
c. Color.Green
d. Color.White
e. Ans : a.
25) Which method will cause a Frame to be displayed?
a. show( )
b. setVisible( )
c. display( )
d. displayFrame( )
Ans : a and b.
26) All the componenet classes and container classes are derived from _________ class.
Ans : Object.
27) Which method of the container class can be used to add components to a Panel.
Ans : add ( ) method.
28) What are the subclasses of the Container class?
Ans : The Container class has three major subclasses. They are :
a. Window
b. Panel
c. ScrollPane
29) The Choice component allows multiple selection.
a. True.
b. False.
Ans : b.
30) The List component does not generate any events.
a. True.
b. False.
Ans : b.
31) Which components are used to get text input from the user.
Ans : TextField and TextArea.
32) Which object is needed to group Checkboxes to make them exclusive?
Ans : CheckboxGroup.
33) Which of the following components allow multiple selections?
a. Non-exclusive Checkboxes.
b. Radio buttons.
c. Choice.
d. List.
Ans : a and d.
34) What are the types of Checkboxes and what is the difference between them?
Ans : Java supports two types of Checkboxes. They are : Exclusive and Non-exclusive.
In case of exclusive Checkboxes, only one among a group of items can be selected at a time. I f an item from the group is selected, the checkbox currently checked is deselected and the new selection is highlighted. The exclusive Checkboxes are also called as Radio buttons.
The non-exclusive checkboxes are not grouped together and each one can be selected independent of the other.
35) What is a Layout Manager and what are the different Layout Managers available in java.awt and what is the default Layout manager for the panal and the panal subclasses?
Ans: A layout Manager is an object that is used to organize components in a container.
The different layouts available in java.awt are :
FlowLayout, BorderLayout, CardLayout, GridLayout and GridBag Layout.
The default Layout Manager of Panal and Panal sub classes is FlowLayout".
36) Can I exert control over the size and placement of components in my interface?
Ans : Yes.
myPanal.setLayout(null);
myPanal.setbounds(20,20,200,200);
37) Can I add the same component to more than one container?
Ans : No. Adding a component to a container automatically removes it from any previous parent(container).
38) How do I specify where a window is to be placed?
Ans : Use setBounds, setSize, or setLocation methods to implement this.
setBounds(int x, int y, int width, int height)
setBounds(Rectangle r)
setSize(int width, int height)
setSize(Dimension d)
setLocation(int x, int y)
setLocation(Point p)
39) How can we create a borderless window?
Ans : Create an instance of the Window class, give it a size, and show it on the screen.
eg. Frame aFrame = ......
Window aWindow = new Window(aFrame);
aWindow.setLayout(new FlowLayout());
aWindow.add(new Button("Press Me"));
aWindow.getBounds(50,50,200,200);
aWindow.show();
40) Can I create a non-resizable windows? If so, how?
Ans: Yes. By using setResizable() method in class Frame.
41) What is the default Layout Manager for the Window and Window subclasses (Frame,Dialog)?
Ans : BorderLayout().
42) How are the elements of different layouts organized?
Ans : FlowLayout : The elements of a FlowLayout are organized in a top to bottom, left to right fashion.
BorderLayout : The elements of a BorderLayout are organized at the
borders (North, South, East and West) and the center of a
container.
CardLayout : The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.
GridLayout : The elements of a GridLayout are of equal size and are laid out using the square of a grid.
GridBagLayout : The elements of a GridBagLayout are organized according to a grid.However, the elements are of different sizes and may occupy
more than one row or column of the grid. In addition, the rows and columns may have different sizes.
43) Which containers use a BorderLayout as their default layout?
Ans : The Window, Frame and Dialog classes use a BorderLayout as their default layout.
44) Which containers use a FlowLayout as their default layout?
Ans : The Panel and the Applet classes use the FlowLayout as their default layout.
45) What is the preferred size of a component?
Ans : The preferred size of a component size that will allow the component to display normally.
46) Which method is method to set the layout of a container?
a. startLayout( )
b. initLayout( )
c. layoutContainer( )
d. setLayout( )
Ans : d.
47) Which method returns the preferred size of a component?
a. getPreferredSize( )
b. getPreferred( )
c. getRequiredSize( )
d. getLayout( )
Ans : a.
48) Which layout should you use to organize the components of a container in a
tabular form?
a. CardLayout
b. BorederLayout
c. FlowLayout
d. GridLayout
Ans : d.
49. An application has a frame that uses a Border layout manager. Why is it probably not a good idea to put a vertical scroll bar at North in the frame?
a. The scroll bar’s height would be its preferred height, which is not likely to be enough.
b. The scroll bar’s width would be the entire width of the frame, which would be much wider than necessary.
c. Both a and b.
d. Neither a nor b. There is no problem with the layout as described.
Ans : c.
49. What is the default layouts for a applet, a frame and a panel?
Ans : For an applet and a panel, Flow layout is the default layout, whereas Border layout is default layout for a frame.
50. If a frame uses a Grid layout manager and does not contain any panels, then all the components within the frame are the same width and height.
a. True
b. False.
Ans : a.
49. If a frame uses its default layout manager and does not contain any panels, then all the components within the frame are the same width and height.
a. True
b. False.
Ans : b.
49. With a Border layout manager, the component at Center gets all the space that is left over, after the components at North and South have been considered.
a. True
b. False
Ans : b.
49. An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout Manager?
a. setLayoutManager(new GridLayout());
b. setLayout(new GridLayout(2,2));
c) setGridLayout(2,2,))
d setBorderLayout();
Ans : b.
55) How do you indicate where a component will be positioned using Flowlayout?
a) North, South,East,West
b) Assign a row/column grid reference
c) Pass a X/Y percentage parameter to the add method
d) Do nothing, the FlowLayout will position the component
Ans :d.
56) How do you change the current layout manager for a container?
a) Use the setLayout method
b) Once created you cannot change the current layout manager of a component
c) Use the setLayoutManager method
d) Use the updateLayout method
Ans :a.
57)When using the GridBagLayout manager, each new component requires a new instance of the GridBagConstraints class. Is this statement true or false?
a) true
b) false
Ans : b.
58) Which of the following statements are true?
a)The default layout manager for an Applet is FlowLayout
b) The default layout manager for an application is FlowLayout
c) A layout manager must be assigned to an Applet before the setSize method is called
d) The FlowLayout manager attempts to honor the preferred size of any components
Ans : a and d.
59) Which method does display the messages whenever there is an item selection or deselection of the CheckboxMenuItem menu?
Ans : itemStateChanged method.
60) Which is a dual state menu item?
Ans : CheckboxMenuItem.
61) Which method can be used to enable/diable a checkbox menu item?
Ans : setState(boolean).
62. Which of the following may a menu contain?
a. A separator
b. A check box
c. A menu
d. A button
e. A panel
Ans : a and c.
62. Which of the following may contain a menu bar?
a. A panel
b. A frame
c. An applet
d. A menu bar
e. A menu
Ans : b
64) What is the difference between a MenuItem and a CheckboxMenuItem?
Ans : The CheckboxMenuItem class extends the MenuItem class to support a menu item
that may be checked or unchecked.
65) Which of the following are true?
a. A Dialog can have a MenuBar.
b. MenuItem extends Menu.
c. A MenuItem can be added to a Menu.
d. A Menu can be added to a Menu.
Ans : c and d.
Java Certification - Questions and Answers
Sun Certified Programmer Practice Exam
Here are the rules:
Allow 2 hours and 15 minutes to complete this exam. You should turn off the telephone, go someplace you won’t be disturbed, check the time on your watch, and begin. Don’t bring any books with you, because you won’t have them during the test. You can take breaks, but don’t look anything up. You can have a piece of scratch paper and a pen or pencil, but you can’t have any crib sheets!
If you get 49 questions right, you’ve hit the 70% mark, and you’ve passed. Good luck!
Questions
Question 1: Which of the following class definitions defines a legal abstract class?
Select all right answers.
a)
class Animal {
abstract void growl();
}
b)
abstract Animal {
abstract void growl();
}
c)
class abstract Animal {
abstract void growl();
}
d)
abstract class Animal {
abstract void growl();
}
e)
abstract class Animal {
abstract void growl() {
System.out.println("growl");
}
}
Question 2: For an object to be a target for a Thread, that object must be of type:
Fill in the blank.
Question 3: What is the proper way of defining a class named Key so that it cannot be subclassed?
a)
class Key { }
b)
abstract final class Key { }
c)
native class Key { }
d)
class Key {
final;
}
e)
final class Key { }
Question 4: What modes are legal for creating a new RandomAccessFile object?
Select all valid answers.
a. "w"
b. "r"
c. "x"
d. "rw"
e. "xrw"
Question 5: Given the following code:
class Tester {
public static void main(String[] args) {
CellPhone cell = new CellPhone();
cell.emergency();
}
}
class Phone {
final void dial911() {
// code to dial 911 here . . ..
}
}
class CellPhone extends Phone {
void emegency() {
dial911();
}
}
What will happen when you try to compile and run the Tester class?
a. The code will not compile because Phone is not also declared as final.
b. The code will not compile because you cannot invoke a final method from a subclass.
c. The code will compile and run fine.
d. The code will compile but will throw a NoSuchMethodException when Tester is run.
e. Phone and CellPhone are fine, but Tester will not compile because it cannot create an instance of a class that derives from a class defining a final method.
Question 6: Which assignments are legal?
Select all valid answers.
a. long test = 012;
b. float f = -412;
c. int other = (int)true;
d. double d = 0x12345678;
e. short s = 10;
Question 7: Given this class definitions:
abstract class Transaction implements Runnable { }
class Deposit extends Transaction {
protected void process() {
addAmount();
}
void undo(int i) {
System.out.println("Undo");
}
}
What will happen if we attempted to compile the code?
Select the one right answer.
a. This code will not compile because the parameter i is not used in undo().
b. This code will not compile because there is no main() method.
c. This code will not compile because Deposit must be an abstract class.
d. This code will not compile because Deposit is not declared public.
e. Everything will compile fine.
Question 8: Which exception might wait() throw?
Fill in the blank.
Question 9: Which of the following are not Java keywords:
abstract double int static
boolean else interface super
break extends long superclass
byte final native switch
case finally new synchronized
catch float null this
char for open throw
class goto package throws
close if private transient
const implements protected try
continue import public void
default instanceof return volatile
do integer short while
Select all valid answers.
a. superclass
b. goto
c. open
d. close
e. integer
f. goto, import
g. goto, superclass, open, close
h. they are all valid keywords
Question 10: Which of the following represents an octal number?
Select all that apply.
a. 0x12
b. 32O
c. 032
d. (octal)2
e. 1
Question 11: What will appear in the standard output when you run the Tester class?
class Tester {
int var;
Tester(double var) {
this.var = (int)var;
}
Tester(int var) {
this("hello");
}
Tester(String s) {
this();
System.out.println(s);
}
Tester() {
System.out.println("good-bye");
}
public static void main(String[] args) {
Tester t = new Tester(5);
}
}
a. nothing
b. "hello"
c. 5
d. "hello" followed by "good-bye"
e. "good-bye" followed by "hello"
Question 12: Write a line of code to use the String’s substring() method to obtain the substring "lip" from a String instance named s that is set to "tulip".
Fill in the blank.
Question 13: There are a number of labels in the source code below. These are labeled a through j. Which label identifies the earliest point where, after that line has executed, the object referred to by the variable first may be garbage collected?
class Riddle {
public static void main(String[] args) {
String first, second;
String riddle;
if (args.length 0)
if (args[index].equals("Hiway"))
milesPerGallon*= 2; System.out.println("mpg: " + milesPerGallon);
}
}
Select the one right answer.
a. The code compiles and displays "mpg: 50" if the command-line argument is "Hiway". If the command-line argument is not "Hiway", the code displays "mpg: 25".
b. The code compiles and displays "mpg: 50" if the command-line argument is "Hiway". If the command-line argument is not "Hiway", the code throws an ArrayIndexOutOfBoundsException.
c. The code does not compile because the automatic variable named index has not been initialized.
d. The code does not compile because milesPerGallon has not been initialized.
e. The code does not compile because the no-args constructor is not written correctly.
Question 16: What will happen when you compile and run this program:
class Array {
public static void main(String[] args) {
int length = 100;
int[] d = new int[length];
for (int index = 0; index < length; index++)
System.out.println(d[index]); }
}
Select the one right answer.
a. The code will not compile because the int[] array is not declared correctly.
b. The code will compile but will throw an IndexArrayOutOfBoundsException when it runs and nothing will appear in the standard output.
c. The code will display the numbers 0 through 99 in the standard output, and then throw an IndexOutOfBoundsException.
d. The code will compile but the println() method will throw a NoSuchMethodException.
e. This code will work fine and display 100 zeroes in the standard output.
Question 17: What is the result of attempting to compile and run the following class?
class Ar {
public static void main(String[] args) {
int[] seeds = new int[3];
for (int i = 0; i < seeds.length; i++)
System.out.println(i); }
}
Select all valid answers.
a. 0
b. 1
c. 2
d. 3
e. the program does not compile because the seeds array is not initialized
Question 18: What method name can you use from the applet to read a String passed to an applet via the tag? (Supply the method name only, without parameters.)
Fill in the blank.
Question 19: Given these class definitions:
class Superclass { }
class Subclass1 extends Superclass { }
and these objects:
Superclass a = new Superclass();
Subclass1 b = new Subclass1();
which of the following explains the result of the statement:
a = b;
Select the one right answer.
a. Illegal at compile time
b. Legal at compile time but possibly illegal at runtime
c. Definitely legal at runtime
Question 20: Given these class definitions:
class Superclass { }
class Subclass1 extends Superclass { }
class Subclass2 extends Superclass { }
and these objects:
Superclass a = new Superclass();
Subclass1 b = new Subclass1();
Subclass2 c = new Subclass2();
which of the following explains the result of the statement:
b = (Subclass1)c;
Select the one right answer.
a. Illegal at compile time
b. Legal at compile time but possibly illegal at runtime
c. Definitely legal at runtime
Question 21: How you can use the escape notation \u to set the variable c, declared as a char, to the Unicode character whose value is hex 0x30A0?
Fill in the blank.
Question 22: Which operators are overloaded for String objects?
Question 20: Given these class definitions:
class Superclass { }
class Subclass1 extends Superclass { }
class Subclass2 extends Superclass { }
and these objects:
Superclass a = new Superclass();
Subclass1 b = new Subclass1();
Subclass2 c = new Subclass2();
which of the following explains the result of the statement:
b = (Subclass1)c;
Select the one right answer.
a. Illegal at compile time
b. Legal at compile time but possibly illegal at runtime
c. Definitely legal at runtime
Question 21: How you can use the escape notation \u to set the variable c, declared as a char, to the Unicode character whose value is hex 0x30A0?
Fill in the blank.
Question 22: Which operators are overloaded for String objects?
Select all valid answers.
a. -
b. +=
c. >>
d. &
• none of these
Question 23: How can you change the break statement below so that it breaks out of both the inner and middle loops and continues with the next iteration of the outer loop?
outer: for (int x = 0; x < 3; x++) {
middle: for (int y = 0; y < 3; y++) {
inner: for (int z = 0; z 3)
d. float myFloat = 40.0;
e. boolean b = (boolean)99;
Question 40: Which label name(s) are illegal?
Select all valid answers.
a. here:
b. _there:
c. this:
d. that:
e. 2to1odds:
Question 41: Given this code:
import java.io.*;
class Write {
public static void main(String[] args) throws Exception {
File file = new File("temp.test");
FileOutputStream stream = new FileOutputStream(file);
// write integers here. . .
}
}
How can you replace the comment at the end of main() with code that will write the integers 0 through 9?
Select the one right answer.
a)
DataOutputStream filter = new DataOutputStream(stream);
for (int i = 0; i < 10; i++)
filter.writeInt(i);
b)
for (int i = 0; i < 10; i++)
file.writeInt(i);
c)
for (int i = 0; i < 10; i++)
stream.writeInt(i);
d)
DataOutputStream filter = new DataOutputStream(stream);
for (int i = 0; i < 10; i++)
filter.write(i);
e)
for (int i = 0; i < 10; i++)
stream.write(i);
Question 42: What keyword, when used in front of a method, must also appear in front of the class?
Fill in the blank.
Question 43: What letters get written to the standard output with the following code?
class Unchecked {
public static void main(String[] args) {
try {
method();
} catch (Exception e) {
}
}
static void method() {
try {
wrench();
System.out.println("a");
} catch (ArithmeticException e) {
System.out.println("b");
} finally {
System.out.println("c");
}
System.out.println("d");
}
static void wrench() {
throw new NullPointerException();
}
}
Select all valid answers.
a. "a"
b. "b"
c. "c"
d. "d"
e. none of these
Question 44: What happens if the file "Ran.test" does not yet exist and you attempt to compile and run the following code?
import java.io.*;
class Ran {
public static void main(String[] args) throws IOException {
RandomAccessFile out = new RandomAccessFile("Ran.test", "rw");
out.writeBytes("Ninotchka");
}
}
Select the one right answer.
a. The code does not compile because RandomAccessFile is not created correctly.
b. The code does not compile because RandomAccessFile does not implement the writeBytes() method.
c. The code compiles and runs but throws an IOException because "Ran.test" does not yet exist.
d. The code compiles and runs but nothing appears in the file "Ran.test" that it creates.
e. The code compiles and runs and "Ninotchka" appears in the file "Ran.test" that it creates.
Question 45: If you run the following code on a on a PC from the directory c:\source:
import java.io.*;
class Path {
public static void main(String[] args) throws Exception {
File file = new File("Ran.test");
System.out.println(file.getAbsolutePath());
}
}
what do you expect the output to be?
Select the one right answer.
a. Ran.test
b. source\Ran.test
c. c:\source\Ran.test
d. c:\source
e. null
Question 46: If you supply a target object when you create a new Thread, as in:
Thread t = new Thread(targetObject);
What test of instanceof does targetObject have to pass for this to be legal?
Select the one right answer.
a. targetObject instanceof Thread
b. targetObject instanceof Object
c. targetObject instanceof Applet
d. targetObject instanceof Runnable
e. targetObject instanceof String
Question 47: What appears in the standard output when you run the Dots class?
class Dots implements Runnable {
DotThread t;
public static void main(String[] args) {
Dots d = new Dots();
d.t = new DotThread();
}
public void init() {
t.start();
t = new DashThread().start();
}
}
class DotThread extends Thread {
public void run() {
for (int index = 0; index < 100; index++)
System.out.print(".");
}
}
class DashThread extends Thread {
public void run() {
for (int index = 0; index < 100; index++)
System.out.print("-");
}
}
a. nothing
b. 100 dots (.)
c. 200 dots (.)
d. 100 dashes (-)
e. 100 dots (.) and 100 dashes(-)
Question 48: When you invoke repaint() for a Component, the AWT package calls which Component method?
a. repaint()
b. update()
c. paint()
d. draw()
e. show()
Question 49: How you can you test whether an object referenced by ref implements an interface named MyInterface? Replace your test here with this test:
if (your test here) {
System.out.println("ref implements MyInterface");
Fill in the blank.
Question 50: What does the following line of code do?
TextField tf = new TextField(30);
Select the one right answer.
a. This code is illegal; there is no such constructor for TextField.
b. Creates a TextField object that can hold 30 rows, but since it is not initialized to anything, it will always be empty.
c. Creates a TextField object that can hold 30 columns, but since it is not initialized to anything, it will always be empty.
d. This code creates a TextField object that can hold 30 rows of text.
e. Creates a new TextField object that is 30 columns of text.
Question 51: Given these code snippets:
Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean(true);
Which expressions are legal Java expressions that return true?
Select all valid answers.
a. b1 == b2
b. b1.equals(b2)
c. b1 & b2
d. b1 | b2
e. b1 && b2
f. b1 || b2
Question 52: Which LayoutManager arranges components left to right, then top to bottom, centering each row as it moves to the next?
Select the one right answer.
a. BorderLayout
b. FlowLayout
c. GridLayout
d. CardLayout
e. GridBagLayout
Question 53: A component can be resized horizontally, but not vertically, when it is placed in which region of a BorderLayout?
Select the one right answer.
a. North or South
b. East or West
c. Center
d. North, South, or Center
e. any region
Question 54: How can you place three Components along the bottom of a Container?
Select the one right answer.
a. Set the Container's LayoutManager to be a BorderLayout and add each Component to the "South" of the Container .
b. Set the Container's LayoutManager to be a FlowLayout and add each Component to the Container.
c. Set the Container's LayoutManager to be a BorderLayout; add each Component to a different Container that uses a FlowLayout, and then add that Container to the "South" of the first Container.
d. Use a GridLayout for the Container and add each Component to the Container.
e. Do not use a LayoutManager at all and add each Component to the Container.
Question 55: What will happen when you attempt to compile and run the following program by passing the Test class to the Java interpreter?
class Test {
public static void main() {
System.out.println("hello");
}
}
Select the one right answer.
a. The program does not compile because main() is not defined correctly.
b. The program compiles but when you try to run the interpreter complains that it cannot find the main() method it needs to run.
c. The program compiles but you cannot run it because the class is not declared as public.
d. The program compiles and runs without an error but does not display anything in the standard output.
e. The program compiles and displays "hello" in the standard output when you run it.
Question 56: Which of the following is a valid way to embed an applet class named Q56 into a Web page?
Select all right answers.
a)
b)
c)
d)
e)
Question 57: How would you make the background color red for a Panel referenced by the variable p?
Fill in the blank.
Question 58: How can you retrieve a circle’s radius value that’s passed to an applet?
a)
public void init() {
String s = getParameter("radius");
doSomethingWithRadius(s);
}
b)
public static void main(String[] args) {
String s = args[0];
DoSomethingWithRadius(s);
}
c)
public static void main(String[] args) {
String s = getParameter("radius");
DoSomethingWithRadius(s);
}
d)
public void init() {
int radius = getParameter("radius");
doSomethingWithRadius(radius);
}
e)
public void init() {
int radius = getParameter();
doSomethingWithRadius(radius);
}
Question 59: What is the result of invoking main() for the classes D and E?
class D {
public static void main(String[] args) {
String s1 = new String("hello");
String s2 = new String("hello");
if (s1.equals(s2))
System.out.println("equal");
else
System.out.println("not equal");
}
}
class E {
public static void main(String[] args) {
StringBuffer sb1 = new StringBuffer("hello");
StringBuffer sb2 = new StringBuffer("hello");
if (sb1.equals(sb2))
System.out.println("equal");
else
System.out.println("not equal");
}
}
Select the one right answer.
a. D: equal; E: equal
b. D: not equal; E: not equal
c. D: equal; E: not equal
d. D: not equal; E: not equal
e. nothing appears in the standard output for either class
Question 60: What does the following code do?
drawArc(50, 40, 20, 20, 90, 180);
Select the one right answer.
a. Draw an arc that is centered at x = 50, y = 40, is 20 pixels wide, as a semicircle from the top of the circle to the bottom along the left-hand side.
b. Draw an arc that is centered at x = 50, y = 40, is 20 pixels wide, as a semicircle from the 3:00 position to the 9:00 position along the bottom of the circle.
c. Draw an arc that is centered at x = 50, y = 40, is 20 pixels wide, as a semicircle from the top of the circle to the bottom along the right-hand side.
d. Draw an arc in a circle whose left side is at 50, whose top is at 40, is 20 pixels wide, as a semicircle from the top of the circle to the bottom along the left-hand side.
e. Draw an arc in a circle whose left side is at 50, whose top is at 40, is 20 pixels wide, as a semicircle from the top of the circle to the bottom along the right-hand side.
Question 61: What does the following code do (if anything)?
drawLine(0, 10, 20, 30);
Select the one right answer.
a. draw a line from x = 0, y = 20 to x = 10, y = 30
b. draw a line from x = 0, y = 10 to the coordinates x = 20, y = 30
c. draw the outline of a box whose left, top corner is at 0, 10 and that is 20 pixels wide and 30 pixels high
d. nothing—this code does not compile because it does not provide the correct number of arguments
e. nothing—this code does not compile because the arguments make no sense
Question 62: What Graphics methods will draw the outline of a square?
Select all right answers.
a. drawRect()
b. fillRect()
c. drawPolygon()
d. fillPolygon()
Question 63: What method from Java 1.0.2 can you use to remove a Component from a user interface display?
Select all right answers.
a. disable()
b. hide()
c. remove()
d. delete()
e. unhook()
Question 64: Returning a value of false in Java 1.0.2 from an event handler:
Select the one right answer.
a. passes that event is passed up the container hierarchy
b. stops that event from being passed up the container hierarchy
c. has no effect on whether the event is passed up the container heirarchy
Question 65: Which statements about garbage collection are true?
Select all valid answers.
a. You can directly free the memory allocated by an object.
b. You can directly run the garbage collector whenever you want to.
c. The garbage collector informs your object when it is about to be garbage collected.
d. The garbage collector reclaims an object’s memory as soon as it becomes a candidate for garbage collection.
e. The garbage collector runs in low-memory situations.
Question 66: If you’d like to change the size of a Component, you can use the Java 1.1-specific method:
Select the one right answer.
a. size()
b. resize()
c. area()
d. setSize()
e. dimension()
Question 67: The setForeground() and setBackground() methods are defined in class:
Select the one right answer.
a. Graphics
b. Container
c. Component
d. Object
e. Applet
Question 68: How many bits are used to maintain a char data type?
Fill in the blank.
Question 69: The && operator works with which data types?
Select all valid answers.
a. int
b. long
c. double
d. boolean
e. float
Question 70: To place a 1 in the high-bit of an int named ref that’s set to 0x00000001, you can write:
Select the one right answer.
a. ref >> 31;
b. ref >>= 31;
c. ref << 31;
d. ref <<= 31;
e. Shifts the bits in an integer to the left by the number of bits specified and fills the right-most bit with 1.
f. Shifts the bits in an integer to the left by the number of bits specified and fills the right-most bit with 0.
Answers and explanations
Question 1: d. An abstract class is defined using the keyword abstract in front of the class keyword and almost always defines at least one abstract method. An abstract class does not have to define an abstract method. If there are no abstract methods in an abstract class, then any subclasses of the abstract class can be instantiated (as long as they are not, in turn, defined using the abstract keyword). (See chapter 1.)
Question 2: "Runnable". Only classes that implement the Runnable interface (and so are of type Runnable) can be targets of threads.
Question 3: e. Use the final keyword in front of the class to make the class unable to be subclassed. (See chapter 1.)
Question 4: b, d. Only "r" and "rw" are legal modes for a RandomAccessFile.
Question 5: c. This code is perfectly fine. (See chapter 1.)
Question 6: a, b, d, and e. The other tries to cast a boolean to an int, which is illegal.
Quesiton 7: c. Since the superclass is abstract and implements Runnable, but does not supply a run() method, the subclass must supply run() or also be declared abstract. (See chapter 1.)
Question 8: "InterruptedException" or "IllegalMonitorException".
Question 9: a, c, d, e. superclass, open, close, and integer are not Java keywords. goto is a keyword, though it isn’t used as of Java 1.1. (See chapter 2.)
Question 10: c. An octal number in Java is preceded by a 0.
Question 11: e. Oh, the tangled web we weave… There are three constructors that come into play. First, the constructor that thakes an int is invoked. This invokes the constructor that takes a String. This invokes the no-args constructor, which displays "good-bye." Then, the constructor that takes a String displays "hello." (See chapter 3.)
Question 12: "s.substring(2, 5)" or "s.substring(2)" or "s.substring(2, s.length())";
Question 13: a. A new String is created based on args[0], but args[0] does not have to be nulled out before first can be garbage collected. As soon as the line with the label d is executed, the object that first has referred to is ready to be garbage collected, because there is no way to recover a reference to this object again. (See chapter 4.)
Question 14: d. The range of integer types goes from minus 2(number of bits - 1) to 2(number of bits - 1) minus 1. (See chapter 5.)
Question 15: c. Even though there is an instance variable named index defined in the Car class, the local or automatic variable named index takes precedence. Since automatic variables do not have a default value, this code will not compile because it is uninitialized when we attempt to access the element in the args array. (See chapter 5.)
Question 16: e. There’s nothing wrong with this code. 100 0's will appear in the standard output. (See chapter 5.)
Question 17: a, b, c. The elements in arrays are initialized to their default values: 0, 0.0, null, false, or \u0000, depending on the data type.
Question 18: "getParameter"
Question 19: c. Assigning a subclass type to a superclass type is perfectly legal and will run fine at runtime.
Question 20: a. You cannot assign an object to a sibling object reference, even with casting.
Question 21: "c = ‘\u30A0’;" You can set a char to a Unicode sequence by matching the template \udddd, where dddd are four hexadecimal digits representing the Unicode character you want. (See chapter 5.)
Question 22: b. Only + and += are overloaded for String objects.
Question 23: b. Changing the break statement to break middle will break out of the loop named using the label middle and continue with the next iteration of the outer loop. The statement continue outer would also have this effect. (See chapter 7.)
Question 24: c. NumberFormatException will be handled in the catch clause for Exception. Then, regardless of the return statements, the finally clause will be executed before control returns to the calling method. (See chapter 8.)
Question 25: a. An explicit cast is needed to assign a superclass type to a subclass type.
Question 26: b. If the object contained in a is not actually a Subclass1 object, the assignment will cause Java to throw a CastClassException. That would be the case in the code in this example.
Question 27: "IOException" or "java.io.IOException"
Question 28: c. A method in a subclass cannot add new exception types that it might throw. Since it’s superclass, Second, does not define any exceptions in its test() method, Third can’t either. (See chapter 8.)
Question 29: c. The method with all double parameters is actually the only version of test() that the Java Virtual Machine can legally coerce the numbers to. The reason the other versions of test() are not invoked is that at least one of the parameters would have to be automatically coerced from a type with greater accuracy to a type with less accuracy, which is illegal. (See chapter 9.)
Question 30: c. The Math method floor() finds the integer closest to but less than the parameter to floor(). The methods round() and ceil() would both result in 91, and min() and max() both require two parameters. (See chapter 10.)
Question 31: "disable"
Question 32: a. Both ceil() and round() will produce 15 from 14.9. The floor() method yields 14. (See chapter 10.)
Question 33: a, b, c, d. The methods Java defines for trig operations include sin(), asin(), cos(), and tan(). (See chapter 10.)
Question 34: d. The method equalsIgnoreCase() would return true for the two Strings a and b in the question. (See chapter 10.)
Question 35: d. The method substring() starts at the first index, inclusive, with 0 being the first character), and ends at the end index - 1 (that is, exclusive of the end index). (See chapter 10.)
Question 36: d. This is the default access control for methods and member variables.
Question 37: b. The concat() method appends the characters passed to it to the characters in the String responding to the method call. The concat() method creates a new String, since Strings cannot be changed once they are created. (See chapter 10.)
Question 38: a. The first line creates a File object that represents the file. By creating a FileOutputStream, you create the file if it does not yet exist, and open that file for reading and writing. (See chapter 11.)
Question 39: d, c, e. You cannot assign an integer to a boolean—not even with casting. Also, the default type for a floating-point literal is double, and you cannot assign a double to a float without casting.
Question 40: c, e. this is a reserved word, so it cannot be used as an identifier (such as a label). 2to1odds starts with a number, so it is also invalid as an identifier.
Question 41: a. In order to write a primitive data type such as an int, you need to use a FilterInputStream subclass such as DataInputStream. This class defines writeInt(), which is perfect for our needs. (See chapter 11.)
Question 42: "abstract"
Question 43: c. Only the "c" from finally gets written out. The exception thrown doesn’t match the exception caught, so the catch block is not executed. Control returns to the caller after finally to see if there is a catch block there to handle this unchecked exception. If there is not (as is the case here), execution comes to an end.
Question 44: e. This code compiles and runs fine. RandomAccessFile implements the DataOutput interface, so it does implement writeBytes(), among others. RandomAccessFile creates the file if it does not yet exist. (See chapter 11.)
Question 45: c. The absolute path includes the drive name and the top-level directories, as well as the file name itself. (See chapter 11.)
Question 46: d. The target object for a Thread must implement Runnable, which means it will pass the test:
targetObject instanceof Runnable
(See chapter 12.)
Question 47: a. The thread's with start() method is never invoked. (This is not an applet, so init() is not automatically invoked.) (See chapter 12.)
Question 48: b. The AWT invokes update() for the Component, which in invokes paint() in its default behavior. (See chapter 13.)
Question 49: "ref instanceof MyInterface"
Question 50: e. TextField defines a constructor that takes the number of columns, as shown in the example. TextField objects can have their text updated at any time, including long after they're created. (See chapter 13.)
Question 51: b. The first yields false, and the others are not legal Java expressions (this is a wrapper type we’re using here…)
Question 52: b. A FlowLayout arranges components in this way. (See chapter 13.)
Question 53: a. North and South only can resize a component horizontally, to the width of the Container. (See chapter 13.)
Question 54: c. Complicated as it might seem, this is the best way to accomplish this goal. First, you set the Container's LayoutManager to be a BorderLayout. Then, you create an intermediate Container and add each Component to this new Container that uses a FlowLayout. Finally, you add that Container to the "South" of the original Container. (See chapter 13.)
Question 55: b. The program will compile fine. However, the Java interpreter specifically looks for a main() method declared as public and static, that returns no value, and that takes an array of String objects as its parameter.
Question 56: c. The tag requires three keywords: code, width, and height.
Question 57: "p.setBackground(Color.red);"
Question 58: a. Use the getParameter() method, passing it the name of the value you want to retrieve. This method retrieves a String representing that value. (You can convert the String to a primitive data type using a wrapper class if you need to.)
Question 59: c. The StringBuffer class does not override equals(). Hence, this class returns false when passed two different objects. (See chapter 6.)
Question 60: d. The four parameters are the left, top, width, height, start angle (0 is the 3:00 position), and the arc angle (the arc ends at start angle plus the arc angle), drawn counter-clockwise.
Question 61: b. The drawLine() method takes four parameters: the starting point and the ending point of the line to draw.
Question 62: a, c. You can use drawRect() to draw a rectangle outline given its upper left point and width and height, and drawPolygon() to draw each of the four points of the square, plus an end point that is the same as the first point.
Question 63: b. The hide() method is more-or-less the opposite of show() and removes a Component from the display.
Question 64: a. Returning false indicates that method did not handle the event, which means AWT passes the event up the container hierarchy looking for someone who does want to handle it.
Question 65: b, c, e. You cannot directly free the memory allocated by an object, though you can set an object reference to null. Also, The garbage collector only runs in low-memory situations, and so does not always reclaim an object’s memory as soon as it becomes a candidate for garbage collection.
Question 66: d. setSize() is specific to Java 1.1.
Question 67: c. These are Component methods. (The setColor() method is defined in the Graphics class.)
Question 68: "16"
Question 69: d. The && operator combines two boolean expressions.
Question 70: d. The << operator shifts the bits the given number of places to the left.
________________________________________
Sun Certified Java Programmer
Practice Exam ( 1 - 10 Questions)
Question 1
What will happen if you compile/run this code?
1: public class Q1 extends Thread
2: {
3: public void run()
4: {
5: System.out.println("Before start method");
6: this.stop();
7: System.out.println("After stop method");
8: }
9:
10: public static void main(String[] args)
11: {
12: Q1 a = new Q1();
13: a.start();
14: }
15: }
A) Compilation error at line 7.
B) Runtime exception at line 7.
C) Prints "Before start method" and "After stop method".
D) Prints "Before start method" only.
Answer
________________________________________
Question 2
What will happen if you compile/run the following code?
1: class Test
2: {
3: static void show()
4: {
5: System.out.println("Show method in Test class");
6: }
7:}
8:
9: public class Q2 extends Test
10: {
11: static void show()
12: {
13: System.out.println("Show method in Q2 class");
14: }
15: public static void main(String[] args)
16: {
17: Test t = new Test();
18: t.show();
19: Q2 q = new Q2();
20: q.show();
21:
22: t = q;
23: t.show();
24:
25: q = t;
26: q.show();
27: }
28: }
A) prints "Show method in Test class"
"Show method in Q2 class"
"Show method in Q2 class"
"Show method in Q2 class"
B) prints "Show method in Test class"
"Show method in Q2 class"
"Show method in Test class"
"Show method in Test class"
C) prints "Show method in Test class"
"Show method in Q2 class"
"Show method in Test class"
"Show method in Q2 class"
D) Compilation error.
Answer
________________________________________
Question 3
The following code will give
1: class Test
2: {
3: void show()
4: {
5: System.out.println("non-static method in Test");
6: }
7: }
8: public class Q3 extends Test
9: {
10: static void show()
11: {
12: System.out.println("Overridden non-static method in Q3");
13: }
14:
15: public static void main(String[] args)
16: {
17: Q3 a = new Q3();
18: }
19: }
A) Compilation error at line 3.
B) Compilation error at line 10.
C) No compilation error, but runtime exception at line 3.
D) No compilation error, but runtime exception at line 10.
Answer
________________________________________
Question No :4
The following code will give
1: class Test
2: {
3: static void show()
4: {
5: System.out.println("Static method in Test");
6: }
7: }
8: public class Q4 extends Test
9: {
10: void show()
11: {
12: System.out.println("Overridden static method in Q4");
13: }
14: public static void main(String[] args)
15: {
16: }
17: }
A) Compilation error at line 3.
B) Compilation error at line 10.
C) No compilation error, but runtime exception at line 3.
D) No compilation error, but runtime exception at line 10.
Answer
________________________________________
Question No :5
The following code will print
1: int i = 1;
2: i <>= 31;
4: i >>= 1;
5:
6: int j = 1;
7: j <>= 31;
9:
10: System.out.println("i = " +i );
11: System.out.println("j = " +j);
A) i = 1
j = 1
B) i = -1
j = 1
C) i = 1
j = -1
D) i = -1
j = -1
Answer
________________________________________
Question No :6
The following code will print
1: Double a = new Double(Double.NaN);
2: Double b = new Double(Double.NaN);
3:
4: if( Double.NaN == Double.NaN )
5: System.out.println("True");
6: else
7: System.out.println("False");
8:
9: if( a.equals(b) )
10: System.out.println("True");
11: else
12: System.out.println("False");
A) True
True
B) True
False
C) False
True
D) False
False
Answer
________________________________________
Question No :7
1: if( new Boolean("true") == new Boolean("true"))
2: System.out.println("True");
3: else
4: System.out.println("False");
A) Compilation error.
B) No compilation error, but runtime exception.
C) Prints "True".
D) Prints "False".
Answer
________________________________________
Question No :8
1: public class Q8
2: {
3: int i = 20;
4: static
5: {
6: int i = 10;
7:
8: }
9: public static void main(String[] args)
10: {
11: Q8 a = new Q8();
12: System.out.println(a.i);
13: }
14: }
A) Compilation error, variable "i" declared twice.
B) Compilation error, static initializers for initialization purpose only.
C) Prints 10.
D) Prints 20.
Answer
________________________________________
Question No :9
The following code will give
1: Byte b1 = new Byte("127");
2:
3: if(b1.toString() == b1.toString())
4: System.out.println("True");
5: else
6: System.out.println("False");
A) Compilation error, toString() is not avialable for Byte.
B) Prints "True".
C) Prints "False".
Answer
________________________________________
Question No :10
What will happen if you compile/run this code?
1: public class Q10
2: {
3: public static void main(String[] args)
4: {
5: int i = 10;
6: int j = 10;
7: boolean b = false;
8:
9: if( b = i == j)
10: System.out.println("True");
11: else
12: System.out.println("False");
13: }
14: }
A) Compilation error at line 9 .
B) Runtime error exception at line 9.
C) Prints "True".
D) Prints "Fasle".
Answer
________________________________________
Question No: 1
D. After the execution of stop() method, thread won't execute any more statements.
Back to Question 1
________________________________________
Question No: 2
D. Explicit casting is required at line 25.
Back to Question 2
________________________________________
Question No: 3
B. You cann't override an non-static method with static method.
Back to Question 3
________________________________________
Question No: 4
B. You cann't override a static method with non-static method.
Back to Question 4
________________________________________
Question No: 5
D.
Back to Question 5
________________________________________
Question No: 6
C.
Back to Question 6
________________________________________
Question No: 7
D.
Back to Question 7
________________________________________
Question No: 8
D. Here the variable '"i" defined in static initializer is local to that block only.
The statements in the static initializers will be executed (only once) when the class is first created.
Back to Question 8
________________________________________
Question No: 9
C.
Back to Question 9
________________________________________
Question No: 10
C. Conditional operators have high precedence than assignment operators.
Sun Certified Java Programmer
Practice Exam (11 - 20 Questions)
Question 11
What will happen if you compile/run the following code?
1: public class Q11
2: {
3: static String str1 = "main method with String[] args";
4: static String str2 = "main method with int[] args";
5:
6: public static void main(String[] args)
7: {
8: System.out.println(str1);
9: }
10:
11: public static void main(int[] args)
12: {
13: System.out.println(str2);
14: }
15: }
A) Duplicate method main(), compilation error at line 6.
B) Duplicate method main(), compilation error at line 11.
C) Prints "main method with main String[] args".
D) Prints "main method with main int[] args".
Answer
________________________________________
Question 12
What is the output of the following code?
1: class Test
2: {
3: Test(int i)
4: {
5: System.out.println("Test(" +i +")");
6: }
7: }
8:
9: public class Q12
10: {
11: static Test t1 = new Test(1);
12:
13: Test t2 = new Test(2);
14:
15: static Test t3 = new Test(3);
16:
17: public static void main(String[] args)
18: {
19: Q12 Q = new Q12();
20: }
21: }
A) Test(1)
Test(2)
Test(3)
B) Test(3)
Test(2)
Test(1)
C) Test(2)
Test(1)
Test(3)
D) Test(1)
Test(3)
Test(2)
Answer
________________________________________
Question 13
What is the output of the following code?
1: int i = 16;
2: int j = 17;
3:
4: System.out.println("i >> 1 = " + (i >> 1));
5: System.out.println("j >> 1 = " + (j >> 1));
A) Prints "i >> 1 = 8"
"j >> 1 = 8"
B) Prints "i >> 1 = 7"
"j >> 1 = 7"
C) Prints "i >> 1 = 8"
"j >> 1 = 9"
D) Prints "i >> 1 = 7"
"j >> 1 = 8"
Answer
________________________________________
Question 14
What is the output of the following code?
1: int i = 45678;
2: int j = ~i;
3:
4: System.out.println(j);
A) Compilation error at line 2. ~ operator applicable to boolean values only.
B) Prints 45677.
C) Prints -45677.
D) Prints -45679.
Practice Exam ( 21 - 30 Questions)
Question 21
What will happen if you compile/run the following code?
1: public class Q21
2: {
3: int maxElements;
4:
5: void Q21()
6: {
7: maxElements = 100;
8: System.out.println(maxElements);
9: }
10:
11: Q21(int i)
12: {
13: maxElements = i;
14: System.out.println(maxElements);
15: }
16:
17: public static void main(String[] args)
18: {
19: Q21 a = new Q21();
20: Q21 b = new Q21(999);
21: }
22: }
A) Prints 100 and 999.
B) Prints 999 and 100.
C) Compilation error at line 3, variable maxElements was not initialized.
D) Compillation error at line 19.
Answer
________________________________________
Question 22
What will happen if run the following code?
1: Boolean[] b1 = new Boolean[10];
2:
3: boolean[] b2 = new boolean[10];
4:
6: System.out.println("The value of b1[1] = " +b1[1]);
7: System.out.println("The value of b2[1] = " +b2[1]);
A) Prints "The value of b1[1] = false"
"The value of b2[1] = false".
B) Prints "The value of b1[1] = null"
"The value of b2[1] = null".
C) Prints "The value of b1[1] = null"
"The value of b2[1] = false".
D) Prints "The value of b1[1] = false"
"The value of b2[1] = null".
Answer
________________________________________
Question 23
Which of the following are valid array declarations/definitions?
1: int iArray1[10];
2: int iArray2[];
3: int iArray3[] = new int[10];
4: int iArray4[10] = new int[10];
5: int []iArray5 = new int[10];
6: int iArray6[] = new int[];
7: int iArray7[] = null;
A) 1.
B) 2.
C) 3.
D) 4.
E) 5.
F) 6.
G) 7.
Answer
________________________________________
Question 24
What is the output for the following lines of code?
1: System.out.println(" " +2 + 3);
2: System.out.println(2 + 3);
3: System.out.println(2 + 3 +"");
4: System.out.println(2 + "" +3);
A) Compilation error at line 3
B) Prints 23, 5, 5 and 23.
C) Prints 5, 5, 5 and 23.
D) Prints 23, 5, 23 and 23.
Answer
________________________________________
Question 25
The following declaration(as a member variable) is legal.
static final transient int maxElements = 100;
A) True.
B) False.
Answer
________________________________________
Question 26
What will happen if you compile/run the following lines of code?
1: int[] iArray = new int[10];
2:
3: iArray.length = 15;
4:
5: System.out.println(iArray.length);
A) Prints 10.
B) Prints 15.
C) Compilation error, you can't change the length of an array.
D) Runtime exception at line 3.
Answer
________________________________________
Question 27
What will happen if you compile/run the folowing lines of code?
1: Vector a = new Vector();
2:
3: a.addElement(10);
4:
5: System.out.println(a.elementAt(0));
A) Prints 10.
B) Prints 11.
C) Compilation error at line 3.
D) Prints some garbage.
Answer
________________________________________
Question 28
What will happen if you invoke the following method?
1: public void check()
2: {
3: System.out.println(Math.min(-0.0,+0.0));
4: System.out.println(Math.max(-0.0,+0.0));
5: System.out.println(Math.min(-0.0,+0.0) == Math.max(0.0,+0.0));
6: }
A) prints -0.0, +0.0 and false.
B) prints -0.0, +0.0 and true.
C) prints 0.0, 0.0 and false.
D) prints 0.0, 0.0 and true.
Answer
________________________________________
Question 29
What will happen if you compile/run this code?
1: int i = 012;
2: int j = 034;
3: int k = 056;
4: int l = 078;
5:
6: System.out.println(i);
7: System.out.println(j);
8: System.out.println(k);
A) Prints 12,34 and 56.
B) Prints 24,68 and 112.
C) Prints 10, 28 and 46.
D) Compilation error.
Answer
________________________________________
Question 30
When executed the following line of code will print
System.out.println(-1 * Double.NEGATIVE_INFINITY);
A) -Infinity
B) Infinity
C) NaN
D) -NaN
Answers

________________________________________
Question No 21
D. Constructors should not return any value. Java won't allow to show with void.
In this case void Q21() is an ordinary method which has the same name of the Class.
________________________________________
Question No 22
C. By default objects will be initialized to null and primitives to their corresponding default values.
The same rule applies to array of objects and primitives.
Back to Question 22
________________________________________
Question No 23
B,C,E and G. You can't specify the array dimension in type specification(left hand side),
so A and D are invalid. In line 6 the array dimension is missing(right hand side) so F is invalid.
You can intialize an array with null. so G is valid.

Back to Question 23
________________________________________
Question No 24
B.
Back to Question 24
________________________________________
Question No 25
A.
Back to Question 25
________________________________________
Question No 26
C. Once array is created then it is not possible to change the length of the array.
Back to Question 26
________________________________________
Question No 27
C. You can't add primitives to Vector. Here 10 is int type primitive.
Back to Question 27
________________________________________
Question No 28
B. The order of floating/double values is
-Infinity --> Negative Numbers/Fractions --> -0.0 --> +0.0 --> Positive Numbers/Fractions --> Infinity.
Back to Question 28
________________________________________
Question No 29
D. Here integers are assigned by octal values. Octal numbers will contain digits from 0 to 7.
8 is illegal digit for an octal value, so you get compilation error.
Back to Question 29
________________________________________
Question No 30
B. Compile and see the result.
Back to Question 30




89 comments:

  1. thanks a ton....
    it really helped me a lot!!!

    ReplyDelete
    Replies
    1. I am happy that you got some benifit. I will post more info. Let me know what type of information you are expecting on this site.

      Delete
  2. Excellent article! We are linking to this particularly great post on our website.
    Keep up the good writing.
    Feel free to visit my blog post making money online

    ReplyDelete
  3. traditionally tantгic mаssage was taught
    in modest сlasses or ωorκshops fοr each etc.
    ρrospect KEY : The сolumnѕ that are еligible to become elemental key.

    ӏ waѕ dіsmayed ... are they? Buу this ebook and female tantric anԁ being a Bhаiravi aге ԁifferent things.
    egg white clеar tantric masѕage was
    аffects them, іt сonfuses them.

    Also visit my web blog website
    Also see my webpage >

    ReplyDelete
  4. ѕchool chancellor Mаrk Wгight, a range of mоuntains plaуer,
    wаs stгetching сombined with
    the thісk-tissuе techniquеѕ оf Thai tаntric massage can be quite
    relaxing. shiatsu is inԁicated fог prevеntivе uѕe, to іdеntіfy and don't even in truth know what I am lacking. Yet, you don't have to bе an hеlps wіth relieѵing sinew stress bу гepοseful the musсles.


    Cheсκ οut my page: web Site

    ReplyDelete
  5. Thanks foг eνery οther іnfοгmatіve
    website. Τhe place еlsе may I am gеtting that kіnd of info
    written in ѕuсh а peгfect way? I haνe а ρrojесt
    that I'm just now operating on, and I'ѵe been at the look out for ѕuch info.


    Alѕо visit mу blog: bramka sms

    ReplyDelete
  6. Ηi, alwayѕ і used tο сhесk
    web ѕite ρosts herе іn
    the early hours in the break of dаy, for the гeasοn that i lіke tο gaіn knowledge οf more аnd more.


    My blog - bramka sms
    Also see my website - bramka sms

    ReplyDelete
  7. In faсt whеn someοne ԁoesn't understand then its up to other viewers that they will assist, so here it happens.

    my page: bramka sms

    ReplyDelete
  8. It is imροrtаnt tо keep skіn smooth and supplе.

    I wiѕh you to gο home. Υou mаy ѕay ' I want you to spread the life of your filter, try to meditate.

    My web-site; tantra london

    ReplyDelete
  9. I always used to study paragraph in news papers but now as I am a user of web so from now I am using net for articles,
    thanks to web.

    My blog :: faraday flashlights

    ReplyDelete
  10. I do accept as true with all the concepts you have offered on your post.
    They are very convincing and can definitely work.
    Nonetheless, the posts are too short for newbies. Could you please
    lengthen them a bit from next time? Thank you for the post.


    Check out my web-site; www.luiscarro.es

    ReplyDelete
  11. What's up it's me, I am also ѵіsitіng thiѕ web page daily, this site iѕ genuinеly pleasant and
    thе peoplе are truly shaгіng pleaѕant thoughts.


    Feel free to vіsit my ѕitе - bramka sms play

    ReplyDelete
  12. This is a topіс that's near to my heart... Cheers! Exactly where are your contact details though?

    Also visit my web-site ... bramka sms play

    ReplyDelete
  13. Attractive sectіon of content. I just stumbled upon your site and in acсeѕsion cаpitаl to assert thаt I
    acquire in fact enjoyed аccount your blog posts.
    Αny waу I'll be subscribing to your feeds and even I achievement you access consistently quickly.

    Feel free to surf to my blog :: bramka gsm

    ReplyDelete
  14. Excellent blog right heгe! Αdditionallу уour ѕite a lοt
    up fast! Whаt web host are уou the usage оf?
    Can I get yоur affiliatе lіnκ fоr
    your host? I desire mу site lοadеd up as quiсkly
    as уouгs lol

    My page - bramka sms

    ReplyDelete
  15. I am sure this piece of writing has touched all the internet people, its really really nice post on building up new website.


    Here is my web page ... World Of Tanks Hack

    ReplyDelete
  16. Good ωay of telling, and fastidiouѕ рost to tаke dаtа regarԁing my pгesеntatiοn subject, whiсh i am gοing to preѕеnt in college.


    my weblog www.Dauerhaarfrei.de

    ReplyDelete
  17. Hello everybody, here every person is sharing such knowledge, thus it's nice to read this webpage, and I used to pay a visit this webpage daily.

    Feel free to visit my weblog; commercial juicers

    ReplyDelete
  18. Attractive portion of content. I just stumbled upon your blog and in accession capital to claim that I get actually enjoyed account your blog posts.
    Anyway I will be subscribing in your feeds or even I achievement you get entry to consistently
    quickly.

    my site - Unknown

    ReplyDelete
  19. Have you ever considered about including a little bit more than just your
    articles? I mean, what you say is valuable and everything.
    However think of if you added some great photos or videos to give your posts more, "pop"!
    Your content is excellent but with images and videos, this blog could undeniably be one of the most beneficial in
    its field. Good blog!

    Feel free to visit my web page: Bestcoconutoilforhair.Com

    ReplyDelete
  20. Very descriptive blog, I loved that bit. Will there be a
    part 2?

    Here is my website: Unknown

    ReplyDelete
  21. I'm extremely inspired along with your writing talents and also with the format to your weblog. Is this a paid theme or did you customize it yourself? Either way stay up the excellent high quality writing, it is rare to peer a nice weblog like this one today..

    Also visit my web site; Unknown

    ReplyDelete
  22. Hi there, its pleasant paragraph concerning media print, we all understand
    media is a enormous source of facts.

    Also visit my blog :: Unknown

    ReplyDelete
  23. Thanks for sharing your thoughts on download 7zip.
    Regards

    ReplyDelete
  24. I tend not to comment, however after looking at a great deal of remarks here "Java Interview Questions - Part2".

    I do have 2 questions for you if it's allright. Could it be only me or do some of these comments look as if they are left by brain dead visitors? :-P And, if you are posting at additional online sites, I would like to keep up with everything fresh you have to post. Would you list of all of all your shared pages like your twitter feed, Facebook page or linkedin profile?

    Feel free to surf to my web-site: Unknown

    ReplyDelete
  25. I am truly delighted to glance at this web site
    posts which consists of tons of valuable facts, thanks
    for providing these kinds of statistics.

    Here is my webpage: stretch Marks

    ReplyDelete
  26. Very good website you have here but I was curious about if you knew of any forums that cover the same topics discussed in this article?

    I'd really like to be a part of group where I can get feedback from other knowledgeable individuals that share the same interest. If you have any suggestions, please let me know. Bless you!

    Feel free to visit my blog post leptin green coffee 800 uk

    ReplyDelete
  27. Hello there! This post could not be written any better!
    Reading this post reminds me of my old room mate! He always kept talking about this.
    I will forward this write-up to him. Pretty sure he will have a good read.
    Many thanks for sharing!

    My web site Http://Laurie49W.Xanga.Com/

    ReplyDelete
  28. I every time emailed this web site post page to all my contacts, as if
    like to read it then my friends will too.

    Visit my site :: Dragonvale Cheats

    ReplyDelete
  29. I think the admin of this web page is genuinely working hard for his website, because here every information
    is quality based information.

    my site :: Coconut Oil For Hair

    ReplyDelete
  30. I'm curious to find out what blog system you're
    utilizing? I'm experiencing some minor security problems with my latest site and I would like to find something more safeguarded. Do you have any recommendations?

    Feel free to surf to my website ... juicer easy

    ReplyDelete
  31. I will right away grasp your rss as I can't find your e-mail subscription hyperlink or e-newsletter service. Do you have any? Please permit me realize so that I may just subscribe. Thanks.

    my webpage: moringa oil

    ReplyDelete
  32. Today, while I was at work, my sister stole my iPad and tested
    to see if it can survive a 30 foot drop, just so she can be a youtube sensation.
    My iPad is now destroyed and she has 83 views. I know this is completely off topic but I had to
    share it with someone!

    Feel free to visit my web site :: PS3 Jailbreak

    ReplyDelete
  33. Hey there! This is kind of off topic but I need some guidance from an established
    blog. Is it tough to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about creating my own but I'm not sure where to start. Do you have any points or suggestions? With thanks

    Here is my web blog ... deer antler spray

    ReplyDelete
  34. WOW just what I was searching for. Came here by searching for raspberry keytone

    Feel free to visit my weblog: red raspberry

    ReplyDelete
  35. Hey! I know this is somewhat off-topic but I had to
    ask. Does operating a well-established blog like yours take a
    large amount of work? I'm brand new to running a blog however I do write in my diary everyday. I'd like to start
    a blog so I can share my personal experience and thoughts online.

    Please let me know if you have any kind of ideas or tips for brand new aspiring blog owners.
    Thankyou!

    Also visit my blog - Dragon City Cheat Engine

    ReplyDelete
  36. Its like you learn my thoughts! You appear to grasp a
    lot approximately this, like you wrote the e-book in it or something.
    I think that you just can do with some % to pressure
    the message house a little bit, but other than that, that is great
    blog. An excellent read. I'll definitely be back.

    my web blog: Psn Code Generator

    ReplyDelete
  37. Magnificent items from you, man. I've keep in mind your stuff prior to and you are simply extremely great. I actually like what you've bought here, really like what you are saying and the best way in which you say it.
    You're making it entertaining and you continue to take care of to keep it smart. I cant wait to read far more from you. This is actually a wonderful web site.

    My site Candy crush saga cheats

    ReplyDelete
  38. It's an remarkable article in favor of all the web people; they will get benefit from it I am sure.

    Check out my web page: Http://Www.Dailymotion.Com

    ReplyDelete
  39. Hey just wanted to give you a quick heads up. The words in your article seem to be running off the screen in Firefox.
    I'm not sure if this is a formatting issue or something to do with browser compatibility but I figured I'd post to let you
    know. The design look great though! Hope you get the issue resolved soon.
    Thanks

    my blog post: Psn Code Generator

    ReplyDelete
  40. Howdy! Quіck questiоn thаt's entirely off topic. Do you know how to make your site mobile friendly? My web site looks weird when browsing from my iphone. I'm
    trying to find a template oг plugin that mіght bе ablе to fiх
    this issue. If you have anу recommenԁations, please share.
    Thank you!

    Also visit my page www.yorktowncenter.com

    ReplyDelete
  41. Hey there, You've done a great job. I'll certainly
    digg it and personally suggest to my friends. I am confident they'll be benefited from this site.

    my web page - playstation 3 jailbreak

    ReplyDelete
  42. I thіnk thе аdmin of this websitе iѕ really working haгԁ in support of hіs ѕite,
    because here every stuff is qualitу based informatiοn.



    Also vіѕit my web-site: www.amazon.com

    ReplyDelete
  43. whoah this weblog is ωonderful i lοve studying уour
    articles. Keep up thе gooԁ work!
    You гecοgnize, many persons arе loοkіng rounԁ for this
    іnfοгmation, you can aiԁ them gгeatly.


    Alѕo visit my webρage; krump-dance.ru

    ReplyDelete
  44. Wow! Finally I got a web sitе from whеre I
    be able to actually take vаluаblе factѕ
    regаrding my ѕtuԁу and knοwledge.


    Ηere is my web site - koreiz.net

    ReplyDelete
  45. Ι νіsited vaгious sites hoωever
    the audio quality for audio songs exіsting at
    thiѕ wеb page is really wondeгful.


    My website: pure green coffee bean extract

    ReplyDelete
  46. I really like what you guys tend to be up too. Thiѕ typе of clever work and coverage!
    Keеp up the superb ωorks guyѕ I've added you guys to our blogroll.

    Feel free to surf to my blog post ... where to buy raspberry ketones

    ReplyDelete
  47. I m sure you are part of. Their first instincts will be to get back together with her good feelings.
    Your first 2 or 3 dates, will always be considered
    less than worthy. I mean, she is not coming back.

    My web page how to attract women tips

    ReplyDelete
  48. If your How to attract women Tips is explaining herself, be understanding, don't be mistaken. That means that there is not a problem.

    ReplyDelete
  49. Hi there, I enjoy reading through your post. I wanted to
    write a little comment to support you.

    Here is my page :: http://pornharvest.com/index.php?q=nubiles+ginger&f=a&p=s

    ReplyDelete
  50. I ωas сurіouѕ іf уou eνег cοnѕidered
    changing thе page layοut οf уour ѕite?
    Its vеry ωell written; I love ωhat уouve got to say.

    But maybe уou could a lіttlе more in the wаy of content so people could connect with it
    bettеr. Yоuvе got an awful lot of text
    for only havіng one or two imаges.
    Maybe уou could spaсe it out bеttеr?


    my homeρage - pure raspberry ketones 500

    ReplyDelete
  51. Thanks for the good writeup. It if truth be told ωas a
    leіsure accοunt it. Glance comрlicаted to mоre аdԁed agreeаblе fгom уou!
    By the wаy, how саn we be in contact?


    my web sіte :: raspberry ketone

    ReplyDelete
  52. Haѵe you ever thought аbout ωгiting an ebooκ or guest authоrіng on other blogs?
    I hаve a blog baseԁ on the same subjects you discuѕs anԁ ωould love to hаѵe уou
    share ѕome stoгies/informatiοn.
    Ι know my ѵieωers would еnjοy уouг ωork.
    If уou're even remotely interested, feel free to shoot me an e mail.

    Feel free to surf to my website :: green coffee bean extract pills

    ReplyDelete
  53. It is the broker's duty to forward the copies of relevant paperwork would be needed before the rates are lower, new Auto Loans For People With Bad Credit, bad credit approved without any issue.

    my site :: bad credit auto loan

    ReplyDelete
  54. Thus one should check the fees of the company and its services.
    Remember, the reason for the pending bill is one of the many consolidate loans companies out there.
    When these factors consolidate loans are combined with your own economic data, such exactly like soaring oil prices, increased inflation, stock market movements, and the resulting market meltdown.
    However, this does not mean that you have proof of
    mailing and a receipt of acceptance.

    My site: homepage

    ReplyDelete
  55. Good article! We will be linking to this particularly
    great content on our website. Keep up the good writing.


    my blog :: vakantie frankrijk huisje ()

    ReplyDelete
  56. I like the valuable info you provide in your articles. I will bookmark your weblog and
    check again here frequently. I'm quite sure I'll learn many new
    stuff right here! Best of luck for the next!



    Here is my web site: The Interlace

    ReplyDelete
  57. Excellent post. I absolutely love this site. Continue the good work!


    Also visit my weblog ... league of legends hack

    ReplyDelete
  58. Hi there very cool blog!! Man .. Excellent .. Superb .

    . I'll bookmark your website and take the feeds additionally? I am happy to seek out numerous useful information right here within the publish, we want develop extra techniques on this regard, thank you for sharing. . . . . .

    Also visit my blog post ... World Of Tanks Hack

    ReplyDelete
  59. It's really a nice and useful piece of info. I am glad that you simply shared this useful info with us. Please stay us up to date like this. Thanks for sharing.

    my website; Minecraft Gift Code Generator

    ReplyDelete
  60. Hello! This is my first comment here so I just wanted to give a quick shout
    out and tell you I genuinely enjoy reading through your articles.
    Can you suggest any other blogs/websites/forums that cover the
    same topics? Thanks a ton!

    my page - Minecraft Gift Code Generator

    ReplyDelete
  61. Aggressive: Women are how to attract beautiful women also
    attracted to men who display the alpha-male characteristic.

    If this is happening, you should lead her. Another very essential factor is that what
    draws females isn't actually the only purpose she will be hard-pressed not to respect and admire you.

    ReplyDelete
  62. Don't hook up with a How To Attract A Women who cheated on you, take everything into consideration such as financial stress, job stress, family stress etc. Although, due to the fact that we rarely see the erect penises of other men except in adult films.

    My web page how to attract women

    ReplyDelete
  63. I visited many websites but the audio quality for audio songs existing at
    this web page is truly wonderful.

    Also visit my web site: waist to height calculator

    ReplyDelete
  64. Thаnkfulness to my father who told mе гegardіng this web ѕite, this webpаge is truly amazing.



    Feel frеe to surf tο my blog - pure green coffee bean extract with gca

    ReplyDelete
  65. penis enlargement oil exercisings experience gained huge popularity over the the global trust Exten Ze and the rationality is its efficacy
    and its ability to show plus outcomes. It is no closed book that most men dream of holding
    a penis expansion oil but demand to takings when you want to
    return them. The more than we worry and pertain method can too have got pathetic
    face effects to a guy. You will learn about the fascinating intimate
    penis elaboration oil creme, but cleaning women can
    be persuasive. Akar sedikit meningkatkan from the extender, rub down your penis to encourage
    circulation.

    Look into my web page :: penis advantage penis advantage review penis advantage reviews penisadvantage penisadvantage review penisadvantage reviews

    ReplyDelete
  66. Before yougive up all hope there are ways to learn how to ways to attract women.
    Anyways, they're here to stay, alas. This way you're not going with him, and the
    next minute you're acting disinterested. So can any one please explain me why they would like to have the unfortunate circumstance of looking back and realizing that something you did pushed her ways to attract women away for good.

    Also visit my web-site: how to attract women tips

    ReplyDelete
  67. michael kors outlet, http://www.michaelkorsoutlets.uk/
    ralph lauren shirts, http://www.poloralphlaurenshirts.us.com/
    football shirts, http://www.cheapfootballshirt.org.uk/
    ray ban sunglasses, http://www.raybansunglassesonline.in.net/
    tiffany outlet, http://www.tiffany-outlet.us.com/
    calvin klein underwear, http://www.calvinklein.in.net/
    tory burch outlet, http://www.toryburch.in.net/
    michael kors factory outlet, http://www.michaelkorsfactoryoutlet.us.org/
    air jordan 4, http://www.airjordan4.org/
    true religion jeans, http://www.truereligionjeansoutlet.com/
    tiffany and co jewelry, http://www.tiffanyandco.in.net/
    nike huarache, http://www.nike-airhuarache.co.uk/
    oakley outlet, http://www.oakleyoutlet.in.net/
    kobe 9, http://www.kobe9elite.us.com/
    vans shoes, http://www.vans-shoes.cc/
    cheap michael kors handbags, http://www.cheapmichaelkorshandbag.in.net/
    nike outlet store, http://www.nikeoutletstore.us/
    cheap jordans, http://www.cheapjordans.us.org/
    air max 2014, http://www.airmax2014.net/
    michael kors wallet, http://www.michaelkorswallet.net/
    hermes bags, http://www.hermesbags.co.uk/
    herve leger, http://www.herveleger.us.com/
    coach outlet, http://www.coachoutletstoreonline.in.net/
    christian louboutin, http://www.scarpelouboutin.it/
    karen millen dresses, http://www.karenmillendressesoutlets.co.uk/
    jordan shoes, http://www.jordanshoes.us.com/
    ray ban, http://www.occhiali-rayban.it/
    0929maoqiuyun

    ReplyDelete
  68. steelers jerseys, http://www.pittsburghsteelersjersey.com/
    michael kors handbags, http://www.michaelkorsusa.us/
    cheap ugg boots, http://www.uggaustralia.in.net/
    kobe bryants shoes, http://www.kobeshoes.us/
    louis vuitton handbags outlet, http://www.louisvuittonhandbag.us/
    true religion outlet, http://www.truereligionjeansoutlet.com/
    cheap nba jerseys, http://www.nbajerseys.us.com/
    san antonio spurs, http://www.sanantoniospursjersey.com/
    tiffany and co, http://www.tiffanyandco.in.net/
    wellensteyn outlet, http://www.barbour.us.com/
    adidas outlet, http://www.adidasoutletstore.us.com/
    canada goose outlet, http://www.canadagooseoutlet.com.co/
    michael kors outlet, http://www.michaelkorsoutlet-store.us.com/
    bottega veneta outlet, http://www.bottegaveneta-outlet.net/
    canada goose outelt, http://www.uggbootscheap.eu.com/
    hollister shirts, http://www.hollistershirts.co.uk/
    tiffany and co, http://www.tiffany-outlet.us.com/
    swarovski outlet, http://www.swarovski-outlet.co.uk/
    basketball shoes,basketball sneakers,lebron james shoes,sports shoes,kobe bryant shoes,kobe sneakers,nike basketball shoes,running shoes,mens sport shoes,nike shoes
    winter jackets, http://www.cybermonday2015.us.com/
    mm1017

    ReplyDelete
  69. Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us.
    Rajnikanth

    ReplyDelete