Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

compile time error and runtime error

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, there :
I met some problems when i do those mock exams.
I always can't figure out the difference between compile time error and runtime error. I knew there was something wrong with the code, but, it is hard to choose between compile time error and runtime time error.
I hope someone can help me if your guys have any experience about that. Where can i find some related resoures to talk about this sort ot topic ?
Hope to hear from u as soon as possi ble.
Have a nice day !
Honggui
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The easiest way to manage the distinctions is to read through code that exhibit either problem. Errors in runtime or compile-time are such fundamental concepts to passing the exam that if they are unfamiliar terms to you, you should probably devote far more time to preparing than you seem to be planning.
The conditions imposed by the compiler include checking for legal syntax, enforcing exception handling, proper nesting, and complete class lookups and correct package declarations.
Runtime errors effectively amount to problems the compiler cannot check, minus the ones the compiler feels it can accurately determine will cause trouble at runtime (and therefore can be pointed to before running the code). As every novice programmer learns, code that will compile is by no means guaranteed to run.
The Sun Certified Java Programmer Exam is not intended for the novices. I recommend you spend six *serious* months with the language at a very bare minimum before taking the exam. Programmers experienced in other languages are likely to need less time to acclimate.
I'd be hard-pressed to believe anyone who says they picked up the criteria for the exam and passed it with little study and no other experience in programming.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Honggui Li
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, Mr. Ernest :
Thank you for your kindly help. I will study harder in order to pass the exam. That is why i haven't registered for SCJP exam 'cause i don't know if i can pass it or not. I took the marcus green's mock exam, my average score is 72. I think i need more practice.
My instructor told me i can pass the exam as long as i study one or two more month, 'cause i got a "A" in his java course. Maybe he thinks i smart enough to pass the test.
I will keep trying. Thanks a lot.
Honggui
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This was actually posted by kishor kotecha
ranch hand, in some Oct 2000 post. I have misplaced the exact URL

Iam cutting & pasting relevant info for your benefit.
HTH
------------------------------------------
--------------------------------------------------------------------------------
Hello Everyone. In the process of my studying for SCJP, I compiled these FEW rules from JLS (Java rules bible). Published here for the benefit of all SCJP candidates. Print and Study them. Will be useful definately. If you have compiled such a list from authenticate source , please let me know. It makes learning easy. I have ommitted few simple rules from here like the expression of if statement must be boolean type.
� A compile-time error occurs if a class has the same simple name as any of its enclosing classes or interfaces.
� A compile-time error occurs if the same modifier appears more than once in a class declaration.
� If a class that is not abstract contains an abstract method, then a compile-time error occurs.
� A compile-time error occurs if an attempt is made to create an instance of an abstract class using a class instance creation expression
� A compile-time error occurs if the name of a final class appears in the extends clause of another class declaration; this implies that a final class cannot have any subclasses.
� A compile-time error occurs if a class is declared both final and abstract, because the implementation of such a class could never be completed.
� Because a final class never has any subclasses, the methods of a final class are never overridden
� It is a compile-time error if a class depends on itself.
� A compile-time error occurs if the same interface is mentioned two or more times in a single implements clause.
� It is a compile-time error for the body of a class declaration to declare two fields with the same name.
� A compile-time error occurs if the same modifier appears more than once in a field declaration, or if a field declaration has more than one of the access modifiers public, protected, and private.
� It is a compile-time error if a blank final class variable is not definitely assigned by a static initializer of the class in which it is declared.
� A blank final instance variable must be definitely assigned at the end of every constructor of the class in which it is declared; otherwise a compile-time error occurs.
� A compile-time error occurs if a final variable is also declared volatile.
� It is a compile-time error for the body of a class to have as members two methods with the same signature.
� If two formal parameters of the same method or constructor are declared to have the same name (that is, their declarations mention the same Identifier), then a compile-time error occurs.
� A compile-time error occurs if the same modifier appears more than once in a method declaration, or if a method declaration has more than one of the access modifiers public, protected, and private.
� A compile-time error occurs if a method declaration that contains the keyword abstract also contains any one of the keywords private, static, final, native, strictfp, or synchronized.
� A compile-time error occurs if a method declaration that contains the keyword native also contains strictfp.
� It is a compile-time error for a private method to be declared abstract.
� It is a compile-time error for a static method to be declared abstract.
� It is a compile-time error for a final method to be declared abstract.
� It is a compile-time error to attempt to override or hide a final method.
� It is a compile-time error for a final method to be declared abstract.
� A compile-time error occurs if a native method is declared abstract.
� A compile-time error occurs if any ClassType mentioned in a throws clause is not the class Throwable or a subclass of Throwable. It is permitted but not required to mention other (unchecked) exceptions in a throws clause.
� A compile-time error occurs if a method declaration is either abstract or native and has a block for its body.
� A compile-time error occurs if a method declaration is neither abstract nor native and has a semicolon for its body.
� If a method is declared void, then its body must not contain any return statement that has an Expression.
� A compile-time error occurs if an instance method attempts to override a static method.
� A compile-time error occurs if a static method hides an instance method.
� If a method declaration overrides or hides the declaration of another method, then a compile-time error occurs if they have different return types or if one has a return type and the other is void. Moreover, a method declaration must not have a throws clause that conflicts with that of any method that it overrides or hides; otherwise, a compile-time error occurs.
� If the overridden or hidden method is public, then the overriding or hiding method must be public; otherwise, a compile-time error occurs.
� If the overridden or hidden method is protected, then the overriding or hiding method must be protected or public; otherwise, a compile-time error occurs.
� If the overridden or hidden method has default (package) access, then the overriding or hiding method must not be private; otherwise, a compile-time error occurs.
� If a return statement appears anywhere within a static initializer, then a compile-time error occurs.
� If the keyword this or the keyword super appears anywhere within a static initializer, then a compile-time error occurs.
� A class may not declare two constructors with the same signature, or a compile-time error occurs.
� It is a compile-time error for a constructor to directly or indirectly invoke itself through a series of one or more explicit constructor invocations involving this.
� A compile-time error occurs if a default constructor is provided by the compiler but the superclass does not have an accessible constructor that takes no arguments.
� a method declared in an interface must not be declared final or a compile-time error occurs. However, a method declared in an interface may be implemented by a method that is declared final in a class that implements the interface.
� A component of an array is accessed by an array access expression that consists of an expression whose value is an array reference followed by an indexing expression enclosed by [ and ], as in A[i]. All arrays are 0-origin. An array with length n can be indexed by the integers 0 to n-1.
� Arrays must be indexed by int values; short, byte, or char values may also be used as index values because they are subjected to unary numeric promotion and become int values. An attempt to access an array component with a long index value results in a compile-time error.
� The type of the Switch Expression must be char, byte, short, or int, or a compile-time error occurs.
� Every case constant expression associated with a switch statement must be assignable to the type of the switch Expression.
� No two of the case constant expressions associated with a switch statement may have the same value.
� Only one default label may be associated with the same switch statement.
� If a break statement is not enclosed by a switch, while, do, or for statement , a compile-time error occurs.
� If no labeled statement with Identifier as its label encloses the break statement, a compile-time error occurs.
� If a continue statement is not enclosed by a while, do, or for statement , a compile-time error occurs.
� If no labeled statement with Identifier as its label encloses the continue statement, a compile-time error occurs.
� A continue statement with label Identifier attempts to transfer control to the enclosing labeled statement that has the same Identifier as its label; that statement, which is called the continue target, then immediately ends the current iteration and begins a new one. The continue target must be a while, do, or for statement or a compile-time error occurs.
� If a label of continue statement is not assigned to while, do, or for statement, a compile-time error occurs.
� A compile-time error occurs if a return statement appears within an instance initializer or a static initializer.
� A return statement with an Expression must be contained in a method declaration that is declared to return a value (�8.4) or a compile-time error occurs. The Expression must denote a variable or value of some type T, or a compile-time error occurs. The type T must be assignable (�5.2) to the declared result type of the method, or a compile-time error occurs.
� It is a compile-time error if a statement cannot be executed because it is unreachable.
� The keyword this may be used only in the body of an instance method, instance initializer or constructor, or in the initializer of an instance variable of a class. If it appears anywhere else, a compile-time error occurs.
------------------------
tvs sundaram
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Honggui,
As Michael Ernest pointed out, it isn't just simply a matter of memorizing rules. You really need to understand how the compiler handles things and that involves being to able to recognize what the code is doing which involves understanding of the language fundamentals.
The best way to learn, imho, is by making sure you grasp the fundamentals; especially inheritance, overriding, overloading and polymorphic behaviour. Then code, code, code. When you think you understand a concept, try writing a piece of code as an illustration. Does it behave the way you thought it would? If not, why not? What did you miss?
Work your way through the exam objectives, one by one, and hunt through the forums, certification guides and mocks for examples.
It's unlikely you'll find a list anywhere that will say 'this always happens at runtime' or 'this always happens at compile time'. What happens is the net result of a combination of many parts.
Hope that's of some help.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic