java does not support multiple inheritance of classes to prevent inheritance of a same method or a variable twice or more and to prevent any discrepancy regarding it but however it supports the same through interface and will not the same discrepancy creep in here? pls explain
class a{ String inv(short s){return "inv";} String inv(short... s){return "var arg";} } class b { public static void main(String args[]) { System.out.println(new a().inv(7)); //compilation fails } }
the ans is:compilation fails since there is no explicit cast during a noraml assignment short s=7; succeeds but y does it fail wen it is passed as an argument
wat will be the answer for this question? pls explain
public class SyncTest { private int x; private int y; private synchronized void setX( int i ) { x = i; } private synchronized void setY( int i ) { y = i; } public void setXY( int i ) { setX(i); setY(i); } public synchronized boolean check() { return x != y; } }
Under which condition will check return true when called from a different class? A. check can never return true. B. check can return true when setXY is called by multiple threads. C. check can return true when multiple threads call setX and setY separately. D. check can return true only if SyncTest is changed to allow x and y to be set separately.
Thread Z holds the lock on object A. Thread X is blocked inside a wait call on ObjectA. What allows thread X to become runnable? A. Thread X is interrupted. B. Thread X is interrupted. C. Thread X�s wait() times out. D. Thread Z calls Thread.sleep(100); E. Thread Z releases the lock on A and calls the notify() method on thread X. F. Thread Z releases the lock on A and calls the notifyAll() method on objectA.
wat will be the answer for this question? pls explain
public class SyncTest { private int x; private int y; private synchronized void setX( int i ) { x = i; } private synchronized void setY( int i ) { y = i; } public void setXY( int i ) { setX(i); setY(i); } public synchronized boolean check() { return x != y; } }
Under which condition will check return true when called from a different class? A. check can never return true. B. check can return true when setXY is called by multiple threads. C. check can return true when multiple threads call setX and setY separately. D. check can return true only if SyncTest is changed to allow x and y to be set separately.
so do u mean that for overriding a method with exception declaration we should either enclose the overriding method in a try catch block or declare those exceptions in the overriding method too ?
which of following correctly describes how variablers are passed to methods?
a)Arguments are always passed by value b)Arguments are always passed by reference c)Arguments that are primitive types are passed by value d)Arguments that are passed with & operator are passed by reference