This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes on compile time constant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "on compile time constant" Watch "on compile time constant" New topic
Author

on compile time constant

velan vel
Ranch Hand

Joined: Nov 15, 2005
Posts: 137
hai ranchers here how is the ans is d
can any one explains

class JSC201 {
static byte m1() {
final char c1 = '\u0001';
return c1; // 1
}
static byte m2(final char c2) {return c2;} // 2
public static void main(String[] args) {
char c3 = '\u0003';
System.out.print(""+m1()+m2(c3)); // 3
}}

What is the result of attempting to compile and run the program?

a. Prints: 13
b. Prints: 4
c. Compile-time error at 1
d. Compile-time error at 2
e. Run-time error
f. None of the above

------------------------------------------------------------------
$ Velan Vel @ SCJP 1.4 $
You learn From Your Failures, Others Will Learn From Your Success
------------------------------------------------------------------
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
What does the compilation error tell you?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
achayya matta
Ranch Hand

Joined: Oct 27, 2005
Posts: 111
hai vel

In method m2() the return type shoud not be either byte or short.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: on compile time constant
 
Similar Threads
final modifier
compile-time constant
Guys Help me Out
Problem returning a byte (was:Why it gives Compiler error?)
complie-time constants