Wednesday, 18 January 2017

level 1 : 07 Step by step interview question to crack the interview.

Hello Everyone ! from this post we will be learning most frequent interview asked question with its explanation. And from this post we will be talking about the way we think before solving or giving answer to interviewer .So keep enjoying . Happy java learning..!!

IF YOU NEED EXPLANATION TO ANY QUESTION JUST COMMENTS FOR REQUEST WITH QUESTION NO.

1. what is data type in java ?
2. what will be the output of this code ?
class callke{
  static int x;
      x=40;
public static void main(String args[]){
System.out.println(x);
}}
if you are guessing answer to be 40 then your are wrong !

SO FROM NOW RULES STARTS FOR INTERVIEW.ALWAYS REMEMBER THE RULES WHICH I WILL BE POSTING IN SEQUENCE MANNER TO 
QUICKLY RESPONSE TO INTERVIEWER.

RULE NO 01 : @class level we can’t initialize data type in two steps.
  
3. what will be the output of this code ?
class callkr{
public static void main(String args[]){
     int x;
         x=40;
System.out.println(x);
}}
if you are guessing answer to be error! then your are again wrong !

RULE NO 02 : initialize the data type before first use which you are
using in method.

4. what is output for below code. give reason?
class callkr{
public static void main(String args[]){
     int x='4';
     System.out.println(x); 
}}
 
5. what is output for below code ?
class callkr{
public static void main(String args[]){
     int x=53;
     System.out.println(x); 
}}
 
6. what is output for below code ?
class callkr{
public static void main(String args[]){
     char x='53';
     System.out.println(x); 
}}
 
7. what is output for below code ?
class callkr{
public static void main(String args[]){
     char x='4';
     System.out.println(x); 
}}


8. what is output for below code ?
class callkr{
public static void main(String args[]){
     char x='53';
     System.out.println(x); 
}}

9. what is output for below code ?
class callkr{
public static void main(String args[]){
     char x1='4';
     char x2='5';
     int sum=x1+x2;
     System.out.println(sum); 
}}

10. what is output for below code ?
class callkr{
public static void main(String args[]){
     char x1='4';
     char x2='5';
     int sum1=x1-48;
     int sum2=x2-48;
     int sum=sum1+sum2;
     System.out.println(sum); 

}}

2 comments:

  1. please do explain the Questions 9, 10.

    ReplyDelete
  2. o/p of Q9 is 105
    bcz all literals are treated as int
    that's why ASCII value of '4' and '5' is added

    Similarly for Q10 o/p is 9

    ReplyDelete