What will be the output of the program?

String x = ne

Loading

Practice Language Fundamentals –

What will be the output of the program?

String x = new String("xyz"); 
String y = "abc";
x = x + y;

How many String objects have been created?

Given a method in a protected class, what access modifier do you us

Loading

Practice Language Fundamentals –

Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?

Which of the following class level (nonlocal) variable declarations

Loading

Practice Language Fundamentals –

Which of the following class level (nonlocal) variable declarations will not compile?

You want a class to have access to members of another class in the

Loading

Practice Language Fundamentals –

You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?

What is the most restrictive access modifier that will allow member

Loading

Practice Language Fundamentals –

What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?

You want subclasses in any package to have access to members of a s

Loading

Practice Language Fundamentals –

You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

boolean bool = true;  
if(bool = false) /* Line 2 */ {
System.out.println("a");
} else if(bool) /* Line 4 */ {
System.out.println("b");
} else if(!bool) /* Line 6 */ {
System.out.println("c"); /* Line 7 */
} else {
System.out.println("d");
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public class If2 {     
static boolean b1, b2;
public static void main(String [] args) {
int x = 0;
if ( !b1 ) /* Line 7 */ {
if ( !b2 ) /* Line 9 */ {
b1 = true;
x++;
if ( 5 > 6 ) {
x++;
}
if ( !b1 )
x = x + 10;
else if ( b2 = true ) /* Line 19 */
x = x + 100;
else if ( b1 | b2 ) /* Line 21 */
x = x + 1000;
}
}
System.out.println(x);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public void foo( boolean a, boolean b) {      
if(a) {
System.out.println("A"); /* Line 3 */
}
else if(a && b) { /* Line 5 */
System.out.println( "A && B");
}
else {/* Line 8 */
if ( !b ) {
System.out.println( "notB") ;
}
else {
System.out.println( "ELSE" ) ;
}
}
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

class Test {     
public static void main(String [] args) {
int i = 0;
while(1) {
if(i == 4) {
break;
}
++i;
}
System.out.println("i = " + i);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

lass Test {     
public static void main(String [] args) {
int I = 0;
outer: while (true) {
I++;
inner: for (int j = 0; j < 10; j++) {
I += j;
if (j == 3)
continue inner;
break outer;
}
continue outer;
}
System.out.println(I);
}
}

 

public class While {     
pub

Loading

Practice Flow Control –

public class While {     
public void loop() {
int x= 0;
while ( 1 ) { /* Line 4 */
System.out.print("x plus one is " + (x + 1)); /* Line 5 */
}
}
}

Which statement is true?

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

int i = 1, j = 10;  
do {
if(i++ > --j) /* Line 4 */{
continue;
}
} while (i < 5);
System.out.println("i = " + i + "and j = " + j); /* Line 9 */