What will be the output of the program?


			  		

Loading

Practice Declarations and Access Control –

What will be the output of the program?

class BoolArray {     
boolean [] b = new boolean[3];
int count = 0;
void set(boolean [] x, int i) {
x[i] = true;
++count;
}
public static void main(String [] args) {
BoolArray ba = new BoolArray();
ba.set(ba.b, 0);
ba.set(ba.b, 2);
ba.test();
}
void test() {
if ( b[0] && b[1] | b[2] )
count++;
if ( b[1] && b[(++count - 2)] )
count += 7;
System.out.println("count = " + count);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Declarations and Access Control –

What will be the output of the program?

class Bitwise {     
public static void main(String [] args) {
int x = 11 & 9;
int y = x ^ 3;
System.out.println( y | 12 );
}
}

 

What will be the output of the program?


			  		

Loading

Practice Declarations and Access Control –

What will be the output of the program?

class BitShift  {     
public static void main(String [] args){
int x = 0x80000000;
System.out.print(x + " and ");
x = x >>> 31;
System.out.println(x);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Declarations and Access Control –

What will be the output of the program?

public class ExamQuestion7 {       
static int j;
static void methodA(int i) {
boolean b;
do {
b = i<10 | methodB(4); /* Line 9 */
b = i<10 || methodB(8); /* Line 10 */
}while (!b);
}
static boolean methodB(int i) {
j += i;
return true;
}
public static void main(String[] args){
methodA(0);
System.out.println( "j = " + j );
}
}

 

Which one is a valid declaration of a boolean?

Loading

Practice Language Fundamentals –

Which one is a valid declaration of a boolean?

What will be the output of the program?


			  		

Loading

Practice Threads –

What will be the output of the program?

class s1 implements Runnable {      
int x = 0, y = 0;
int addX() {
x++;
return x;
}
int addY() {
y++;
return y;
}
public void run() {
for(int i = 0; i < 10; i++)
System.out.println(addX() + " " + addY());
}
public static void main(String args[]) {
s1 run1 = new s1();
s1 run2 = new s1();
Thread t1 = new Thread(run1);
Thread t2 = new Thread(run2);
t1.start();
t2.start();
}
}

 

What will be the output of the program?


			  		

Loading

Practice Threads –

What will be the output of the program?

class MyThread extends Thread {      
MyThread() {
}
MyThread(Runnable r) {
super(r);
}
public void run() {
System.out.print("Inside Thread ");
}
}
class MyRunnable implements Runnable {
public void run() {
System.out.print(" Inside Runnable");
}
}
class Test {
public static void main(String[] args) {
new MyThread().start();
new MyThread(new MyRunnable()).start();
}
}

 

What will be the output of the program?


			  		

Loading

Practice Threads –

What will be the output of the program?

class MyThread extends Thread {     
public static void main(String [] args) {
MyThread t = new MyThread();
t.start();
System.out.print("one. ");
t.start();
System.out.print("two. ");
}
public void run() {
System.out.print("Thread ");
}
}

 

What will be the output of the program?


			  		

Loading

Practice Threads –

What will be the output of the program?

class MyThread extends Thread {
MyThread() {
System.out.print(" MyThread");
}
public void run() {
System.out.print(" bar");
}
public void run(String s) {
System.out.println(" baz");
}
}
public class TestThreads {
public static void main (String [] args) {
Thread t = new MyThread() {
public void run() {
System.out.println(" foo");
}
};
t.start();
}
}

 

As compared to sliding bearings, ball and roller bearing have

Loading

Practice Threads –

As compared to sliding bearings, ball and roller bearing have