InterviewSolution

Java programming basic and advance interview question answer. Java coding example. Banking, Financial, Computer related and Software related abbreviation. Computer storage devices. PC to PC files transfer using WiFi. Introduction to Network Topology. Difference Between Hub Switch and Router. Difference Between Wired and Wireless Network. Advantages and Disadvantages of Computer Network. Networking Interview Questions for Experienced. Basic Networking Interview Questions.

Monday, October 1, 2018

70+ Java Programming Example

Java Programming Example

JAVA PROGRAMMING EXAMPLE
Java Programming Example









Page No:-7

291.What will be the output of the following program?

 class Java
 {
 public static void main(String args[])
{
for(int i=2;i<8;i++)
{
if(i%3==0)
System.out.println(i+"\t");
}
}
  }
a. 3    
    6
b. 2
    6
c. compile-time error
d. Run-time error


292.What will be print of the following code?

class Avi
{
public static void main(String args[])
{
double a = 9.5;
int b = (int)a;
System.out.println("a is="+ a+"\n b is="+b);
}
}
a. a is=9.0
    b is=9
b. a is=9.5   
    b is=9  
c. Compile-time error
d. None Of Above

293.What will be the output of the following program?

public class Java
{
public static void main(String args[])
{
int a = 0;
a = a++ + a;
System.out.println("K = " +a);
}
}
a. k= 0 
b. K = 2 
c. K= 1   
d. Compile-time Error.

294.What will be print of the following code?

class Avi
{
private int i;
public static void main(String[] args) {
Avi avi = new Avi();
System.out.println(avi.i);
}
}
Output will be?
a.1
b.0   
c.2
d.Compile-time error

295.Which answer is correct of the following code?

class Java{
public static void main(String args[])
{
int i=4, j=5;
if (i==4)
if (j==5)
System.out.println("JAVA");
else
System.out.println("Programming ");
System.out.println("Language");
}
}
output will be?
a. JAVA
b. JAVA    
    Language
c. Error page will be show
d. null


296.What is the output of the following program.

class Avi
{
static int b = 1;
public static void main(String args[])
{
System.out.println(b+" ");
System.out.println(b);
}
public void m(int b)
{
b += 2;
}
}

a. 1 , 3 
b. 3 , 1 
c. 1 , 1 
d. 1 , 0


297.What will be the output of the following programme?

class Array{
public static void main(String args[]){
int array[]=new int[3];
for(int i=1;i<array.length;i++)
array[i]=i;
for(int j=0;j<array.length;j++)
System.out.println(array[j]);
}
}
Output will be?
a. 0
   1
   2
   3
b. 0   
   1
   2
c. Compile-time error
d. Run-time error  .


298.What will be the output of the following code.

class Java
{
public static void main(String[] args)
{
boolean s = false;
int j = 1;
do
{
j++;
s =! s;

while (s);
System.out.println(j);
}
 }
a. run time error
b. compile-time error
c. 7
d. 3    

299.What will be the output of the following program.

public static void main(String[] args)
{
System.out.print("Java\nProgramming");
}
a. Java\nProgramming 
b. Java Programming
c. Java        
    Programming
d. Compile-time error


300.What will be the output of the following code.

 public static void main(String[] args)
{
      byte a=64,b,c;
     b= (byte) (a<<2);
     c=(byte) (a>>2);
     System.out.println("b is="+b);
     System.out.println("c is="+c);
}
output will be:-
a. b is=0     
    c is=16
b. b is=0
    c is=8
c. Compile-time error
d. Run-time error


301.Which answer is correct of the following code?
    
   class Avi
    {
   public static void main(String args[])
    {
          int a=6,d=3,b=4,e=1;
          System.out.println( - -a * d + e *b --);
     }
     }
a. 20
b. 21
c. 22   
d. 23

302.Method calling by parameter?

class Sum { void display(int a, int b) { System.out.println("Sum of the Number is="+(a+b)); } } public class Java { public static void main(String args[]) { Sum sum = new Sum(); sum.display(12, 15); } }

OutPut:-Sum of the Number is=27


303.What will be the output of the following program?

    class Avi 
    {    
        public void main( String[] args ) 
        {  
            System.out.println( "Java" + args[1] ); 
        } 
    }
a. Java
b. Run-time error
c. Compile-time error   
d. None of the above


304.What will be the output of the following programme?

class Array{
public static void main(String args[]) {
String[] Names={"Avi","Joy","Ankita"};
Names[2]="Akash";
for(int i=0;i<Names.length;i++)
System.out.println(Names[i]);
}
}
Output will be?
a.Avi   
  Joy
  Akash
b.Avi
  Joy
  Ankita
c.Avi
  Ankita
  Akash
d.run-time error  

305.What will be the output of the following code?

class Java
{
public static void main(String[] args)
{
int k = 0;
int j = 0;
for (int i=0;i<=5;i++)
{
k++;
if (i==2) break;
j++;
}
System.out.println(k+", "+j);
}
}
a.Compile time error
b.3,2    
c.run time error
d.None of above

 [  Ans:- 291.a   292.b   293.c   294.b   295.b   296.c   297.b   298.d   299.c   300.a   301.c   302.a   303.c   304.a   305.b  ] 
PRENEXTHOME
page 1
page 2

page 3


page 5
page 6
                         
page 8

No comments:

Post a Comment