Examveda

What would be the output of the following fraction of code?
int Integer = 34 ;
char String = 'S' ;
System.out.print( Integer ) ;
System.out.print( String ) ;

A. Does not compile as Integer and String are API class names.

B. Throws exception.

C. 34

D. S

E. 34 S

Answer: Option E


This Question Belongs to Java Program >> Data Types And Variables

Join The Discussion

Comments (12)

  1. Chetan Dandekar
    Chetan Dandekar:
    9 months ago

    However, Java does allow this because variable names are case-sensitive.

  2. Krishna Sankarasetti
    Krishna Sankarasetti:
    2 years ago

    Got this error after running this program:

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    Type mismatch: cannot convert from String to char

  3. Shashikant Jagtap
    Shashikant Jagtap:
    5 years ago

    Both integer and String are inbuilt classes. So we can't use variable of that name.

  4. Nikhil Rj
    Nikhil Rj:
    7 years ago

    Predefined class can be used as identifier.

  5. Gayatri Budha
    Gayatri Budha:
    7 years ago

    How can a class Integer and String be used in variable?

  6. Julakanti Sai
    Julakanti Sai:
    8 years ago

    if S is capital in the name string of char type wat would be the answer

  7. Madugula Nagendra
    Madugula Nagendra:
    8 years ago

    here string represented as single quote

    String s='s';

  8. Sonu Shaw
    Sonu Shaw:
    8 years ago

    String is a reference type in java so we can use it as identifiers.

  9. Sachin Dandge
    Sachin Dandge:
    8 years ago

    predefined java classes and interfaces can be used as an identifiers but its not a good programming practice.

  10. Dipti Chavan
    Dipti Chavan:
    8 years ago

    what is the ouptut of following programm fragment?justify.
    byte b=50;
    b=b*50;

  11. Mahendra Pirtani
    Mahendra Pirtani:
    9 years ago

    here Integer and String are Defined classes in java so how can we use this as a Identifier

  12. Tushar Zagade
    Tushar Zagade:
    9 years ago

    String and Integer are not reserved words so no need to worry

Related Questions on Data Types and Variables