ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Can we add two byte variables and assign the result to a 
byte variable ?
b=b1+b2   where b,b1,b2 are byte types
 Question Submitted By :: Hari Kumar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Can we add two byte variables and assign the result to a byte variable ? b=b1+b2 where b,b1,b2 are byte types
Answer
# 1
yes.But you have to cast that variable before adding.

eg:
byte b=(byte)b1+(byte)b2
 
Is This Answer Correct ?    1 Yes 8 No
Guest
 
  Re: Can we add two byte variables and assign the result to a byte variable ? b=b1+b2 where b,b1,b2 are byte types
Answer
# 2
yes, but u require type casting because the the binary
operation in java should atleast returns Integer values


example : 
    byte a=12;
    byte b=23;
//  byte c=a+b; //Not OK,bcoz a+b is an int value
    int c=(byte)a+b;   // OK
 
Is This Answer Correct ?    7 Yes 1 No
M. Abhishek
 
 
 
  Re: Can we add two byte variables and assign the result to a byte variable ? b=b1+b2 where b,b1,b2 are byte types
Answer
# 3
Yes,the following is the right way to do so
byte b1=21;byte b2=11;
	 byte b;
	 b=(byte)(b1+b2);
 
Is This Answer Correct ?    7 Yes 1 No
Rajesh
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
how do you store phone numbers using java collections Bosch4
can abstract class have constructor how can you achive this ? Fidelity3
What are packages and name a few?  4
What is meant by constructor?  4
For which statements we use a label? Wipro3
When is an object in the mean to garbage collection?  3
What classes of exceptions, thrown by a throw statement?  2
What is an enumeration class?  2
What are the OOPS concepts in Java ? Satyam3
How will you override default serialization mechanism in java  2
What is an array and a vector? How they different from each other?  3
what is difference between throw and throws in exception?  16
What is the functionality of Webserver?  2
y cant i declare method like public final static show()  2
How you can create a radio buttion using Checkbox class?  1
How many statements can be created with one connection in jdbc? Polaris2
wht is customised exception? Prudential1
What are types of Java applications?  4
How many bits are used to represent unicodde,ASCII,UTF-16 and UTF-8 characters?  2
Hi friends, i am new to java. can you explain how java is secured.  1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com