scjp Questions
2
I'm practising for the SCJP exam using cram notes from the Internet.
According to my notes the >> operator is supposed to be signed right shift, with the sign bit being brought in from the ...
3
Solved
Ok, So I know that an anonymous inner class is either implicitly extending a parent class or implementing an interface, and therefore a constructor of the superclass will need to be called. However...
Yale asked 27/12, 2013 at 20:10
3
Solved
Can someone explain to me like I'm five why I get different behaviour for two of four primitive types representing integers in Java? AFAIK all four are signed and they all use the most significant ...
Eoin asked 6/12, 2013 at 22:31
1
while debugging the java Multithreading program i put breakpoints. after start method is invoking the control is not going to run menthod can you please let me know the debug procedure.
sample cod...
Bulger asked 19/8, 2013 at 13:11
3
Solved
I was solving some questions for my OCA prepration. I found this problem at Oracle's website listing sample questions for exam.
Code:
public class MyStuff {
MyStuff(String n) { name = n; }
String...
2
Solved
So I'm studying for the SCJP from the Kathy Sierra book.
In the chapter for strings, this is a question:
String s1 = "spring ";
String s2 = s1 + "summer ";
s1.concat( "fall ");
s2.concat(s1);
s1 +...
Latonia asked 22/5, 2013 at 11:2
3
Solved
I've been reading a section on Statics in the SCJP study guide, and it mentions the following :
static methods can't be overridden,
but they can be redefined
What does redefining actually me...
4
Solved
Are both SCJP 6 and OCJP 6 exams same? I am going to write OCJP 6 exam this month end but I am preparing SCJP 6 book by Kathy Seirra.
And for practice I am preparing Kathy seirra's "OCP Jav...
5
I'm studying for the SCJP exam and I ran into an issue I can't really wrap my head around.
The book says you can't widen and then box, but you can box and then widen.
The example for not being abl...
3
Solved
If enum implements Comparable so why can't compare with < or >?
public class Dream
{
public static void main(String... args)
{
System.out.println(PinSize.BIG == PinSize.BIGGER); //false
Sy...
2
Solved
I've been studying for OCJP (former SCJP) and I came across the following example which uses LinkedHashSet:
public class Test{
int size;
public Test(int s){
this.size = s;
}
@Override
pub...
Striking asked 21/10, 2012 at 19:51
4
Solved
I've got some doubts regarding protected identifier. In the first chapter of Sun Certified Java Programmer Study Guide by K.Sierra I found the following information:
"Once the subclass-outside-th...
Dratted asked 12/10, 2012 at 14:58
4
Solved
Given:
public class Spock {
public static void main(String[] args) {
Long tail = 2000L;
Long distance = 1999L;
Long story = 1000L;
if ((tail > distance) ^ ((story * 2) == tail)) {
System....
5
Solved
Given this sample code:
Runnable r = new Runnable() {
public void run() {
System.out.print("Cat");
}
};
Thread t = new Thread(r) {
public void run() {
System.out.print("Dog");
}
};
t.start()...
3
Solved
While playing with classloaders i got the following exception:
Exception in thread "main" java.lang.ClassCastException: xxx.Singleton cannot be cast to xxx.Singleton
Does this mean that an insta...
Apollonian asked 8/8, 2012 at 13:46
4
Solved
After reading some of the SCJP certification last night, I got thinking about switch statements and how the expressions are evaluated, and I'm a little puzzled by something.
Java won't let you swi...
Gearhart asked 8/8, 2012 at 10:30
3
Solved
If you have an enum such as
enum Coffee {
BIG,
SMALL
}
and a class that has an instance variable like this of the enum:
public class MyClass {
private Coffee coffee;
// Constructor etc.
}
...
5
Solved
I've read the whole SCJP6 book Sierra and Bates book, scored 88% the exam.
But still, i never heard of how this kind of code works as it's not explained in the generics chapter:
Collections.<T...
Gman asked 8/6, 2012 at 8:44
1
Solved
I've written an utility method in Java:
public static final ImmutableSortedSet<TimeUnit> REVERSED_TIMEUNITS = ImmutableSortedSet.copyOf(
Collections.<TimeUnit>reverseOrder(),
EnumSet...
Riccio asked 8/6, 2012 at 8:33
2
Solved
While answering to a question about that here: https://stackoverflow.com/a/9872630/82609
I tried to do the following:
Comparator<String>[] comparators = new Comparator[] {...};
It works! ...
Auriscope asked 27/3, 2012 at 9:7
4
Solved
I was asked this question:
String s = "abc"; // creates one String object and one
// reference variable
In this simple case, "abc" will go in the pool and s will refer to it.
String s = new Stri...
3
Solved
In the following code example:
class Parent {
int x =5;
public Integer aMethod(){
System.out.print("Parent.aMthod ");
return x;
}
}
class Child extends Parent {
int x =6;
public Integer ...
Wailoo asked 27/12, 2011 at 17:9
3
Solved
In the following program
class ZiggyTest2 {
public static void main(String[] args){
double x = 123.456;
char c = 65;
int i = 65;
System.out.printf("%s",x);
System.out.printf("%b",x);
Sy...
Pimple asked 25/12, 2011 at 14:20
7
Solved
When i run the following example i get the output 0,2,1
class ZiggyTest2{
static int f1(int i) {
System.out.print(i + ",");
return 0;
}
public static void main(String[] args) {
int i ...
2
Solved
In preparation for the SCJP (or OCPJP as it's now known) exam, I'm being caught out by some mock questions regarding pass-by-(reference)value and immutability.
My understanding, is that when you p...
Niedersachsen asked 2/12, 2011 at 13:8
© 2022 - 2024 — McMap. All rights reserved.