What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { boolean boo = true; int i; if(boo) i = boo ? 3: 2; else i = boo ? 4: 1; System.out.println("Value of i is " +i); } },Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher
What result comes when we compile and run following code:
public class R4RSCJPTest 
{
    public static void main(String args[]) 
    {
	 boolean boo = true;
	 int i;
	 if(boo) 
              i = boo ? 3: 2;
	 else 
              i = boo ? 4: 1;
	 System.out.println("Value of i is " +i);
    }
}

More interview questions and answers

What result comes when we compile and run following code: class R4RSCJPTest { public static void main(String args[]) { int i,j,k,l=0; k = l++; j = ++k; i = --j; System.out.println("Value of i is " +i); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { char c; int i; c = 'A'; //1 i = c; //2 c = i + 1; //3 i++; //4 } }

Select correct signed of left shift operator.

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i = 1; boolean t = true; boolean f = false, boo; boo = (t && ((i++) == 0)); boo = (f && ((i+=2) > 0)); System.out.println("Value of i is " +i); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i = 1; boolean t = true; boolean f = false, boo; boo = (t & ((i++) == 0)); boo = (f & ((i+=2) > 0)); System.out.println("Value of i is " +i); } }

Primitive Instance Variables

Object Reference Instance Variables

Array Instance Variables

Local Primitives

Local Objects

Local Arrays

Command-Line Arguments to Main

Declarations and Modifiers

Class Declarations and Modifiers

Class Access

Default Access

Public Access

Other (Nonaccess) Class Modifiers

Final Classes

Abstract Classes

Creating an Abstract Superclass and Concrete Subclass

Method and Variable Declarations and Modifiers.

Member Access

Public Members

Private Members

Local Variables and Access Modifiers

Nonaccess Member Modifiers

Final Methods

Final Arguments

What result comes when we compile and following code: public class R4RSCJPTest { public static void main(String args[]) { byte i = 4; i = (byte)~i; System.out.println("Value of i is " +i); } }

Select operator which we use in Java for bitwise inversion.

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i,j; i = 1 & 5; j = 2 | 7; System.out.println("Value of i is " + i + ", Value of j is " + j ); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i = -1; int j = i>>3; int k = j & 129; System.out.println("Value of k is " +k); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i,j; i = 1 | 5 ; j = 2 ^ 7; System.out.println("Value of i is " + i + ", Value of j is " + j); } }

Synchronized Methods

Native Methods

Strictfp Methods

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { boolean boo = true; int i; if(boo) i = boo ? 3: 2; else i = boo ? 4: 1; System.out.println("Value of i is " +i); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { boolean boo = false; int i; if(boo) i = boo ? 3: 2; else i = boo ? 4: 1; System.out.println("Value of i is " +i); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i = 0; if(i < 0) i = 1; switch(i) { case 2: System.out.println(2); case 0: System.out.println(0); case 1: System.out.println(1); break; case 3: System.out.println(3); default: System.out.println(4); break; } } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i, j; i = 7 >> 2; j = 7 >>> 2; System.out.println("Value of i is " +i+",Value of j is " +j); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i; i = -2 << 1; i = i >> 3; i = i >>> 2; System.out.println("Value of i is " +i); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i; i = -2 << 1; i = i >>> 2; i = i >> 1; System.out.println("Value of i is " +i); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i = -4; i = i << 2; System.out.println("Value of i is " +i); } }

Select correct signed right shift operator from following.

Select shift operator which are not used in Java.

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i = 0, J = 1, k; if(i) k = 2; else k = 1; if(j) k = 0; else k = 3; System.out.println("Value of k is " +k); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { for(int i = 0; i < 2; i++) { for(int j = 1; j >= 0; j--) { if(i == j) continue; System.out.println("Value of i is "+ i + ", Value of j is " + j); } } } }

What result comes when we compile and run following code: public class Test { public static void main(String args[]) { for(int i = 0; i < 2; i++) { for(int j = 1; j >= 0; j--) { if(i == j) break; System.out.println("Value of i is "+ i + ", Value of j is " + j); } } } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { outer: for(int i = 0; i < 2; i++) { for(int j = 2; j >= 0; j--) { if(i == j) continue outer; System.out.println("Value of i is " +i+ ", Value of j is " +j); } } } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { outer: for(int i = 0; i < 2; i++) { for(int j = 2; j >= 0; j--) { if(i == j) break outer; System.out.println("Value of i is " +i+ ", Value of j is " +j); } } } }

Variable Declarations

Instance Variables

Local (Automatic/Stack/Method) Variables

Final Variables

Transient Variables

Volatile Variables

Static Variables and Methods

Accessing Static Methods and Variables

Declaration Rules

Source File Structure

Using Import Statements

Formatting the main() Method

Interface Implementation

Declaring an Interface

Declaring Interface Constants

Implementing an Interface

What result comes when we compile and run following code: class Test { public static void main(String args[]) { int arr[] = new int[2]; System.out.println(arr[0]); } }

Select legal declaration and defination of a method.

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i = 1; int j = 0; boolean boo = true; boolean boo1; boo1 = (boo && 0<(i+=2)); boo1 = (boo && 0<(i+=1)); boo1 = (boo && 0<(j+=2)); boo1 = (boo || 0<(j+=1)); System.out.println("Value of i is " + i + ", Value of j is " + j ); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int i = 1; int j = 0; boolean boo = false; boolean boo1; boo1 = (boo && 0<(i+=2)); boo1 = (boo && 0<(i+=1)); boo1 = (boo && 0<(j+=2)); boo1 = (boo || 0<(j+=1)); System.out.println("Value of i is " + i + ", Value of j is " + j ); } }

What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { char A = '\u0005'; if ( A == 0x0005L ) System.out.println("Equal"); else System.out.println("Not Equal"); } }

What result comes when we compile and run following code: class R4RSCJPTest { public void methodTest(int i) { System.out.println("Value of i is " +i); } public int methodTest(int i) { System.out.println("Value of i+1 is " + (i+1)); return (i+1); } public static void main(String args[]) { R4RSCJPTest a = new R4RSCJPTest(); a.methodTest(4); } }

What result comes when we compile and run following code: class R4RSCJPTest { public static void main(String arg[]) { int a[]={2,2}; int b=0; a[b]=b=1; System.out.println(a[0]); System.out.println(a[1]); } }

Select two valid character contants from followings.

Select correct statement to execute given program: public class R4RSCJPTest { int planets; static int suns; public void gaze() { int i; // .... write statements here .... } }

Select all valid statement from followings.

Select the valid ways which refer to the class from outside the package net.codemaster. package net.codemaster; public class code { // ...Write some statements here... }

public class myprog { public static void main(String [] args) { signed int a = 20; for (int b=0; b<10; b++, a--) System.out.print(" " + a); } }

What result comes when we compile and run following code: protected class R4RSCJPTest { public static void main(String args[]) { String str1 = "xyz", str2 = "pqr",str; str = str1 + str2; System.out.println(str); } }

Which word is reserved word in the Java programming language in the following option?

Which one of these lists contains only Java programming language keywords?

Which two are keywords?

A top level class without any modifier is accessible by....... (Select most appropriate answer)

Which three are valid declarations of a char?

Which two are valid declarations of a String?

Which one is a valid declaration of a boolean?

What is the numerical range of a char?

Which three are valid declarations of a float?

From below select three correct statement in Java.

Which three are legal array declarations?

public class myprog { public static void main(String [] args) { int [] [] [] a = new int [3] [] []; int x,y; a[0] = new int[3][]; a[1] = new int[3][]; a[2] = new int[4][]; for (x=0; xGiven the following, public class myprog { public static void main(String [] args) { byte [][] big = new byte [8][8]; byte [][] x = new byte [3][2]; byte x3 = 6; byte x2 [][][][] = new byte [3][4][2][3]; .................................. } } which of the following lines of code could be inserted at dotted line , and still allow the code to compile?

Which two will declare an array and initialize it with Ten numbers?

Which will legally declare, construct, and initialize an array?

Which four describe the correct default values for array elements of the types indicated?

Given the following, public class myhorse { public static void main(String [] args) { Horse [][] theHorse = new Horse[3][]; System.out.println(theHorse[2][0].toString()); } } class Horse {} what is the result?

Given the following, public class myprog { public static void main(String [] args) { String names [] = new String[10]; for (int i=0; i < args.length; i++) names[i] = args[i]; System.out.println(names[2]); } } and the command line invocation is java i a b what is the result?

Given the following, public class CommandArgs { public static void main(String [] args) { String s1 = args[1]; String s2 = args[2]; String s3 = args[3]; String s4 = args[4]; System.out.print(" args[2] = " + s2); } } and the command-line invocation, java CommandArgs 1 2 3 4 , what is the result?

Given the following, public class CommandArgsTwo { public static void main(String [] argh) { String [] args; int x; x = argh.length; for (int y = 1; y <= x; y++) { System.out.print(" " + argh[y]); } } } and the command-line invocation, java CommandArgsTwo 1 2 3

R4R provides free online tutolrails ,examples for Freshers and experts .We cover core java, tutorials, spring, Hibernate, python, struts, struts 2,c language, spring boot,PHP,MYSQL,C#,ASP.NET,WPF,WCF,Photoshop , JSP, programming, example, Interview questions and answer