File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Am i correct? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Am i correct? " Watch "Am i correct? " New topic
Author

Am i correct?

Doit
Ranch Hand

Joined: Aug 03, 2000
Posts: 169
1. What would be the result of attempting to compile and run the following piece of code?
public class Test {
static int x; public static void main
(String args[ ])
{System.out.println("Value is " + x);}
}
A.The output "Value is 0" is printed.
B.An object of type NullPointerException is thrown.
C.An "illegal array declaration syntax" compiler error occurs.
D.A "possible reference before assignment" compiler error occurs.
E.An object of type ArrayIndexOutOfBoundsException is thrown.

ANS: A

2. What should you use to position a Button within an application Frame so that the size of the Button is NOT affected by
the Frame size?
A.a FlowLayout
B.a GridLayout
C.the center area of a BorderLayout
D.the East or West area of a BorderLayout
E.the North or South area of a BorderLayout
ANS: A

3. Which is the advantage of encapsulation?
A.Only public methods are needed.
B.No exceptions need to be thrown from any method.
C.Making the class final causes no consequential changes to other code.
D.It changes the implementation without changing the interface and causes no consequential changes to other code.
E.It changes the interface without changing the implementation and causes no consequential changes to other code.

ANS: D
4. Which of the following most directly supports retrieval of stored objects based on a unique key of String type?
A.Map
B.Set
C.List
D.Collection
E.Enumeration

ANS: A

5. Which statement is true about a non-static inner class?
A.It must implement an interface.
B.It is accessible from any other class.
C.It can only be instantiated in the enclosing class.
D.It must be final if it is declared in a method scope.
E.It can access private instance variables in the enclosing object.
ANS: E

6. Which are keywords in Java (select all that apply)?
A.NULL
B.sizeof
C.friend
D.extends
E.synchronized

ANS: D,E
7. Which declares an abstract method in an abstract Java class?
A.public abstract method();
B.public abstract void method();
C.public void abstract Method();
D.public void method() {abstract;/}
E.public abstract void method() {/}
ANS: A,B
- Thanks
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
Hi doit,
i'm with u except for the last one.
for which only B is correct.
option A is wrong because it does not specifies any return type for the function.
for the rest i agree with u.
regards
deekasha
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I agreed. For the last question you need to specify what the method will return. Therefore, A is not correct.
------------------
vidya
Ranch Hand

Joined: Aug 08, 2000
Posts: 47
Hi !
For the first question, won't the compiler say ' x may not have been initialised' ? But that is not one of the options..
But , I doubt, will it compile without you initialising the variable?
please tell me what I am missing...
thanks,
Vidya.
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Vidya,
Read the question again carefully. The variable x is a class variable and not a local variable. Hence it gets initialized to the default value( 0 for integral type ).
Class variables are automatically initialized to their default values, unless other values are specified by you. On the other hand, local variablesdon't get auto-initialized and cannot be referenced before initialization. The only exception to this rule is arrays. Arrays whether local or class-level, always gets initialized.
Hope this helps,
Ajith


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
vidya
Ranch Hand

Joined: Aug 08, 2000
Posts: 47
O , yes Ajith, I got it!!
Thanx a lot!
Vidya.
 
 
subject: Am i correct?