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

one q on class

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carefully examine the following class:

What is the result:

A. Prints out "Done the test" and nothing else.
B. Program produces no output but terminates correctly.
C. Program does not terminate.
D. The program will not compile.
E. The program generates a runtime exception.
F. The program prints out "The end" and nothing else.
G. The program prints out "Done the test" and "The end"

Select the most appropriate answer.

i answered d, but the correct answer is f.
in this eg, an instance of test5 is created, but there is no instance of the class created to store the reference?
can we create a statement like test5 = new test5();

(tags added and code formatted)
[ November 15, 2004: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[B]Please format your code and place it within tags[/B],

then we can spend less time to answer the question
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code above is equivalent to:


Can you see why?

(Yes, "Test5 = new test5();" is also wrong but it has no effect until another problem is fixed)
[ November 15, 2004: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is waht v get if we decomopile the class file.
it gives u a good insight to what compiler is keeping with it.
=======================================
import java.io.PrintStream;

public class Test5
{

public Test5()
{
}

public static void main(String args[])
{
System.out.println("The end");
}
}
=======================================

well,i used jad for decompilation.
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The closing comment delimiter */ is not there. As a result, starting from "This is ..." to "...another comment" is treated as comment.

Joyce
 
reply
    Bookmark Topic Watch Topic
  • New Topic