• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

lost a interview chance after written test was submitted

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a written test before an interview. I have finished the test then their IT manager replied that my code was not good.
just want to know do you have any improvement suggestions of my answers?
written test file






 
Marshal
Posts: 69407
276
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You would fall down for poor formatting because the code lines are too long. You would fall down for incorrect use of the main() method, and you would fall down for not using object orientation in the first class; everything is marked static.
 
Rancher
Posts: 179
15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd probably have got more feedback if you posted in a different forum.

Anyways I'll code review
---

General comment: No javadoc comments on anything. This isn't good.

General comment: Including unit tests would have been a good idea if you had time to do so.


This line of code would be cleaner if you set it up a as a Map<Product, List<Product>>


Code can go in a constructor if you make this stuff non-static.


Reduce the size of your main method to a single line run call. For example move all of this code into a private (non-static) method called "run" and then call:



Poor exception handling here. What does a NumberFormatException mean? Tell that to the user.
Why make the call to showMenu() again? The try won't break the loop.


I don't like this scanner.nextLine(). It's better to always consume the newline rather than only if they enter something wrong.


This code has no purpose


Magic number here (and other) needs to be refactored into a constant.


I'd prefer this be handled with a loop than a recursive method call.


This exception type doesn't make sense for the context it's thrown in.


Split up long lines with newlines.


Purpose of remove here is unclear and should be commented.


Non-descriptive enum value names here


Intention of this code is unclear and should be explained (maybe this is just because it's called A, B, C)


Functionality of this line is unclear.
 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Zachary Griggs wrote:
Functionality of this line is unclear.



Not only unclear... it's also dividing two int values and then converting it to Double. This is probably not quite what was needed: for example if you divide 1 / 2 and then convert to double, you get zero. Whereas you probably wanted to get 0.5 instead. You need to cast either the dividend or the divisor to double before the division takes place.
 
Campbell Ritchie
Marshal
Posts: 69407
276
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Zachary Griggs wrote:. . . a good idea if you had time to do so. . . .

Interviewers assume that the applicants will all take a lot of trouble about the submission and will all make sure to take the time to create a polished product. If the idea is to reduce fifty applications to five to interview, the reviewing process will be very fast, and ruthless. You see the iffy declaration in line 3 and the very long line 57 [or 80], and you stop reading.

[edit]Add “[or 80]”
 
Ranch Hand
Posts: 143
5
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ben luk, i.e the OP of this post.

Could you please post an overview of the problem and your solution ? It is really hard to figure out what you are doing. The more hard you make it for others to understand you, the less likely people will help you or hire you. The main problems I noticed at quick glance - No unit tests for your code, no comments and no overview of the code. Those are big red flags to begin with.
 
Campbell Ritchie
Marshal
Posts: 69407
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The OP handed in code regarded as poor and fell at the second hurdle. He hasn't been back to this forum, so you probably won't get any more information, I am afraid.
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic