Sample Questions

Aptitude/Logical Reasoning

				
			
A. V
B. W
C. Y
D. U

Java

		
	public class MyClass {
	    public static void main(String[] args) {
	        String msg;
	        String pre = "This program was called with ";
	        String post = " as first argument.";
	
	        String arg1 = new String((args.length > 0) ? "'" + args[ 0 ] + "'" : "no argument");
	        msg = arg1;
	        arg1 = null;             // (1)
	        msg = pre + msg + post;  // (2)
	        pre = null;              // (3)
	
	        System.out.println(msg);
	
	        msg = null;              // (4)
	        post = null;             // (5)
	        args = null;             // (6)
	    }
	}
	
A. After the line labeled (1)
B. After the line labeled (2)
C. After the line labeled (3)
D. After the line labeled (4)

C++

		
	int main(){
	    static int a=2,y=4,z=8;
	    static int *array1[2]={&a,&y};
	    static int *array2[2]={&y,&z};
	    int* (*arr[2])[2]={&array1,&array2};
	    std::cout << *(*arr[0])[1],  *(*(**(arr+1)+1));
		return 0;
	}
	
A. 1
B. 2
C. 4
D. Compilation Fails

Coding