art mudick

Greenhorn
+ Follow
since Feb 15, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by art mudick

Which of the following statements are true?

1) static methods do not have access to the implicit variable called this
2) a static method may not be overriden
3) a static method may not be overriden to be non-static
4) a static method may not be overloaded
My answer is 1, 2 and 3. But 2 is not listed. Why? I think static methods cannot be overridden only hidden by the subclass. What should be my choices for the question from exam point of view. Can someone tell me.
class shifttest
{
public static void main (String args[])
{
int i=1;
int j =0;
long l=100;
j= i << j;
i = i << l; // The right side operator type long doesn't
// give an error Why?
// shifted 100 mod 32 = 4, 1<< 4 =16
System.out.println("i: " + i + "j: " + j);
char c = 'a';
System.out.println(c>>1);
}
}
My question is when the number of bits to be shifted are more then the number of bits defined in the primitive type it is shifted n modulo 32 for integer. Why doesn't it complain about the right side operator which is a long primitive? Does it implicitly convert the number to an int?
If a method is defined in the base class and is not overridden in the subclass then it can be called by the instance of the subclass directly unless it is declared private in the base class? Can someone please clarify.
Am i right in understanding that an inner class defined inside a method cannot access local variables in other member functions of outer class. Since the scope of any local variable is only within the method where it is defined.
There was a question on Marcus Green mock exam 2 which highlighted on this. I did not look it carefully and got it wrong. Can someone verify this please.
Why is answer C not valid. Please explain
For what reasons might a thread stop execution?
a) A thread with higher priority began execution.
b) The thread's wait() method was invoked.
c) The thread invoked its yield() method.
d) The thread's pause() method was invoked.
e) The thread's sleep() method was invoked.
I think the answer is a,b,e. I am not sure about choice d. Should we take d as right as yield temporarily pauses executing a thread
Here is a question from MindQ test
import java.io.*;
class Super
{
int methodOne( int a, long b ) throws IOException
{ // code that performs some calculations
}
float methodTwo( char a, int b )
{ // code that performs other calculations
}
}
public class Sub extends Super
{
}
Which of the following are legal method declarations to add to the class Sub? Assume that each method is
the only one being added.
a) public static void main( String args[] ){}
b) float methodTwo(){}
c) long methodOne( int c, long d ){}
d) int methodOne( int c, long d ) throws ArithmeticException{}
e) int methodOne( int c, long d ) throws FileNotFoundException{}
I chose answer a,b,d and e. Could someone tell me if it right.