Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: please answer my question.

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default please answer my question.

    public class Java1
    {
    public static void main(String ar[])
    {
    short s=0;
    int x=7;
    int y=8;
    int z=123456;
    s+=z;    //line 1
    }
    }
    what is the data type of s in line 1?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: please answer my question.

    The data type is used when a variable is defined. Look at the definition for s. Its datatype is there.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: please answer my question.

    Data type is Short only

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: please answer my question.

    @srinivasjsf Check your spelling. Short (a class) is not the same as short (a primitive).
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Struggling with answer to question
    By StanTheMan in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 14th, 2013, 02:36 PM
  2. Can You Answer This basic Question "DDD
    By amiel in forum Java Theory & Questions
    Replies: 4
    Last Post: July 2nd, 2013, 09:08 AM
  3. [SOLVED] Array question - confused by answer
    By Techstudent in forum Collections and Generics
    Replies: 2
    Last Post: April 29th, 2013, 06:22 PM
  4. [SOLVED] please answer this question,tq
    By suganti selvaraj in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 6th, 2013, 12:50 AM
  5. please answer some basic question
    By togaurav in forum Java Theory & Questions
    Replies: 5
    Last Post: April 16th, 2011, 07:58 AM