aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes set of questions 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 "set of questions" Watch "set of questions" New topic
Author

set of questions

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi explain with the output


public class Q1eec {
static void test(int i) {
int j = i/2;
int k = i >>> 1;
assert j == k : i;
}

public static void main(String[] args) {
test(0);
test(2);
test(-2);
test(1001);
test(-1001);
}
}






Given the following code, which statements concerning the objects referenced through the member variables i, j and k are true, given that any thread may call the methods a(), b() and c() at any time?

class Counter {
int v = 0;
synchronized void inc() { v++; }
synchronized void dec() { v--; }
}
public class Q7ed5 {
Counter i;
Counter j;
Counter k;
public synchronized void a() {
i.inc();
System.out.println("a");
i.dec();
}
public synchronized void b() {
i.inc(); j.inc(); k.inc();
System.out.println("b");
i.dec(); j.dec(); k.dec();
}
public void c() {
k.inc();
System.out.println("c");
k.dec();
}
}





Which statements are true regarding the execution of the following code?

public class Q3a0a {
public static void main(String[] args) {
int j = 5;

for (int i = 0; i<j; i++) {
assert i < j-- : i > 0;
System.out.println(i*j);
}
}
}






What will be written to the standard output when the following program is run?

class Base {
int i;
Base() { add(1); }
void add(int v) { i += v; }
void print() { System.out.println(i); }
}
class Extension extends Base {
Extension() { add(2); }
void add(int v) { i += v*2; }
}
public class Qd073 {
public static void main(String[] args) {
bogo(new Extension());
}
static void bogo(Base b) {
b.add(8);
b.print();
}
}
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
any one please
Joe Sondow
Ranch Hand

Joined: Apr 10, 2005
Posts: 195
Parameswaran, I usually try to answer your questions, but I think I can do you a better service by suggesting that you ask them in a way that makes it easier for others to help you. A few suggestions:

1. Use the UBB "code" tags around your code to preserve the indentation.

2. Make sure your code uses proper indentation so it's easier to read.

3. Only ask one question per discussion thread. If you have 4 questions, post 4 separate topics. This helps readers focus on one issue and discuss that one issue.

4. Proofread your post to make sure it makes sense. This topic, for example, has several mock exam questions that ask "Which statements are true about this?" but you forgot to list any of the possible statements.

5. Read and understand everything in the How to Ask Questions the Smart Way faq.
[ March 12, 2006: Message edited by: Joseph Sondow ]

SCJA 1.0 (98%), SCJP 1.4 (98%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: set of questions