File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Miscellaneous Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Miscellaneous" Watch "Miscellaneous" New topic



Joined: Dec 26, 2000
Posts: 2
1.static final int MY_FLAG = 16;
Method removeFlag takes int x and returns int value which do not
contains flag MY_FLAG. Which of the following implementations are
A. return (x & ~MY_FLAG);
B. return ~(x | MY_FLAG);
C. return (x & MY_FLAG > 0 ? x-MY_FLAG : x);
D. return ~(~x | MY_FLAG);
3. Which of the following declarations correctly declare an array:
A. int arr1[][] = new int[10][10];
B. int arr2[] = new int[10][10];
C. int arr3[10][] = new int[10][];
D. int arr4[][] = new int[10][];
4.String s1 = "ABCDEF";
String s2 = s1.substring(0, 3);
String s3 = s1.substring(3, 6);
String s4 = s2.toUpperCase() + s3.toLowerCase();
How many String objects creates this code?
A. 4
B. 5
C. 6
D. StringIndexOutOfBoundsException is thrown
5. Given method which extracts and returns file extension from the
given file name:
static String getName(String s) {
int n = s.indexOf('.');
return s.substring(n); }
Which of the following statements are true?
A. This method always returns a wrong extension
B. This method may return a wrong extension under certain
C. This method may throw unchecked exception

D. This method works fine
public class Test2Q22{
private void test() {
String a = null;
String b = "b";
try {
// Complex processing
throw new MalformedURLException("test");
if(b ==null)
throw new EOFException("test");
// Complex processing
catch (MalformedURLException e) {
System.out.println("Caught MalformedURLException");
catch (EOFException e) {
System.out.println("Caught EOFException");
finally {
try {
System.out.println("End finally " + a.trim());
catch(Exception e) {
System.out.println("End finally with an exception");
System.out.println("End processing");
static public void main(String[] a) {
new Test2Q22().test();
/* Select all valid answers
a) End finally
b) Caught MalformedURLException
c) Caught EOFException
d) End finally with an exception
e) End processing
f) Compilation error. Cannot add try/catch block inside a finally block*/
The correct ans is b and d.Please explain.
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Please post only one question per thread. This will help maintain the focus of the discussion without digression. You may post as many questions as possible.
Also, your name 'nikhilnandu' does not comply with the JavaRanch naming policy. Please choose one that meets the requirements.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
I agree. Here's the link:
subject: Miscellaneous
It's not a secret anymore!