• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

answers format v/s real exam , a must read

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the following question and the answers pattern
[question from the marcus green exam for scjp 1.4]

-----------------------------------------------------
What will happen when you attempt to compile and run the following code?

class Base{
private Integer iwNum;
public Base(Integer iw){
iwNum=iw;
System.out.println(iwNum);
}
}
public class Moss{
public static void main(String argv[]){
Moss m = new Moss();
m.blossom();
}
public void blossom(){
float f = 10;
knavesmire(f);
}

public void knavesmire(double d){
int i = (int)d;
Integer iw = new Integer(i);
Base b= new Base(iw);

}
}

1) Compile error, double cannot be cast to int
2) Compile error, a value assigned to a float must have a decimal component
3) Compilation and output of 10
4) Compilation and output of 10.0
-----------------------------------------------------


Please answer to the following
a) Compile error ---" double cannot be cast to int "
Compile error--" a value assigned to a float must have a decimal component"

Is the "reason for the compiler error" explicitly mentioned
in the real exam???

PLEASE HELP ME OUT WITH THIS???
 
author
Posts: 9031
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey bradpitt ioooio,

First off, we'd like you to change your display name to your real first and last name! We've found it keeps things friendlier when ranchers use their real names, thanks.

Now on to your question. Most commonly the question will have a simple "Compilation fails" option, but sometimes you'll get a question something like this, or something like "Fails due to an error on line 7" or "Fails due to an error on line 9". You WON'T need to know exact compiler messages, but it's a good idea to know why a piece of code is failing. As far as exceptions are concerned, you will need to understand why and when the exceptions listed in the objectives can be thrown.

hth,

Bert
 
santhosh sharma
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u so much Bert

Suppose the answer pattern is as ,
a)compiler error --"invalid access modifier"
b)compiler error --"instance variable accessed from static context"
c)Prints 100
d)Prints 80

Then u can eliminate the options a and b as wrong just by looking
at 2 or 3 lines without reading the entire code
and then just concentrate on the output ,
doesnt this save time in the exam!!
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dont u think that answer to the q shd be 10 and not compier error?
 
santhosh sharma
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Absolutely the answer is 10 ,
My point is this , if the answers format in the real exam[scjp 1.4]
was given as shown the above example , then it takes around
30 seconds to determine the answer

Only one answer is correct among the 4 choices so

a)b) can be eliminated just by looking at 2 lines
d) can be eliminated as
System.out.println(new Integer(10)); can never print 10.0

hence c should be the answer !!!
see it just takes 10 seconds , thus u can save a lot of time in the exam
 
You showed up just in time for the waffles! And this 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