Primitive Instance Variables ,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
Primitive Instance Variables

Instance variable is basically a member variables, its basically defined at the class level.We have a example for the primitive instance variable which is following as : 

public class BirthDate {
int year; // Instance variable
public static void main(String [] args) {
BirthDate bd = new BirthDate();
bd.showYear();
}

public void showYear() {
System.out.println(\"The year is \" + year);
}
}

In this example the integer year is signifies as a class member .When the code is execute,Its gives the variable year a value of zero, the default value for primitive number instance variable.

Variable Type         |      Default Value
-------------------------------------------------
Object reference       | null(not referencing any object
--------------------------------------------------
byte, short, int, long  | 0
-------------------------------------------------
float, double              | 0.0
--------------------------------------------------
boolean                    | false
--------------------------------------------------
char                         | u0000

More interview questions and answers
Choose correct collection interface which we use to represent stored elements into in particular sequence order.
Declaring an Array
Constructing an Array
Select correct method which is defined in Object class and can also used to convert an Integer Object into primitive int type.
Which are the legal identifiers from below.Select three correct options.
Select correct width (in bits) of double primitive type in Java.
What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int x = 15, y; if(x < 15) y = 3; if(x>= 15) y = 4; System.out.println("Value of y is " + y); } }
Initializing an Array
What result comes when we compile and run following code: class R4RSCJPTest { int i; int j; String str; public static void main(String args[]) { R4RSCJPTest test = new R4RSCJPTest(); System.out.println("String is " + test.str + " " + test.i + " " + test.j); } }
Select three correct options related to Java programming language.
What result comes when we compile and run following code: class R4RSCJPTest { public static void main() { System.out.println("Welcome"); } }
Select correct options which is use to declare main method.
Initializing Elements in a Loop
Declaring, Constructing, and Initializing on One Line
What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int x, y; int z = 4; z++; y = 3; y++; z = y = z = 2; System.out.println("Value of z is = "+z ); } }
Constructing and Initializing an Anonymous Array
Arrays of Primitives
Arrays of Object References
What result comes when we compile and run following code: public class R4RSCJPTest { public static void main(String args[]) { int x, y; int z = 4; z++; y = 4; y++; z+= y-= x = 2; if( z == 6) z-= 3; else z+= 3; System.out.println("Value of z is "+z ); } }
Array Reference Assignments for One-Dimensional Arrays
Array Reference Assignments for Multidimensional Arrays
Using a Variable or Array Element That Is Uninitialized and Unassigned
What result comes when we compile and run following code: public class R4RSCJPTest { int i = 1; public static void main(String args[]) { int i = 2; i = new_i(i); System.out.println("New value of i is " +i); } public static int new_i(int i) { i = 3; i *= 4; return i; } }
What result comes when we compile and run following code: public class R4RSCJPTest { int i = 1; public static void main(String args[]) { int i = 2; new_i(i); System.out.println("New value of i is " +i); } public static void new_i(int i) { i = 3; i *= 4; } }
What result comes when we compile and run following code: public class R4RSCJPTest { int i[] = {0}; public static void main(String args[]) { int i[] = {1}; new_i(i); System.out.println("New value of i[0] is " +i[0]); } public static void new_i(int i[]) { i[0] = 2; i[0] *= 3; } }
What result comes when we compile and run(with command line argument R4R welcome in intellegence world. in following code: public class R4RSCJPTest { public static void main(String args[]) { System.out.println(args[0]+" "+args [args.length-1]); } }
What result comes when we compile and run(with command line argument like: R4R welcomes you in intelligence world) following code: public class test { public static void main(String args[]) { System.out.println(args[0]+" "+args.length); } }
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); } }