Open Side Menu Go to the Top

12-11-2013 , 01:19 AM
here's an example:

Quote:
For a class called Rectangle:

Rectangle ab = new Rectangle();
Rectangle bc;

bc = ab;
How many objects are created here? (I put 1)

is bc a deep copy or a shallow copy? (I put shallow. this wasn't how the question was worded and i may be remembering it wrong)

then a question about constructors that basically showed 2 examples of code, one where the constructor was public void, and the other where it was just public. it asked which one was legal, and I put both are legal. Correct?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
12-11-2013 , 01:39 AM
Quote:
Originally Posted by jmakinmecrzy
here's an example:

How many objects are created here? (I put 1)

is bc a deep copy or a shallow copy? (I put shallow. this wasn't how the question was worded and i may be remembering it wrong)

then a question about constructors that basically showed 2 examples of code, one where the constructor was public void, and the other where it was just public. it asked which one was legal, and I put both are legal. Correct?
You can't have "public void" for a constructor, but everything else sounds right to me.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:40 AM
Quote:
Originally Posted by jmakinmecrzy
here's an example:

Quote:
For a class called Rectangle:

Rectangle ab = new Rectangle();
Rectangle bc;

bc = ab;
How many objects are created here? (I put 1)

is bc a deep copy or a shallow copy? (I put shallow. this wasn't how the question was worded and i may be remembering it wrong)
Correct on both.

Quote:
then a question about constructors that basically showed 2 examples of code, one where the constructor was public void, and the other where it was just public. it asked which one was legal, and I put both are legal. Correct?
The former is a legal method but not a constructor. So depending on the wording, your answer may be correct or not.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:42 AM
Quote:
Originally Posted by jmakinmecrzy
my java final was 100 questions and just had a lot of tracing and "what's wrong with this code" type questions. I hate those because I always rely on the compiler when I'm actually doing programming to catch that sort of ****.

tracing questions were easy, then she started using a lot of terminology I wasn't totally solid on because we never went into detail too much about pointers and memory allocation and stuff like that. Bunch of deep copy/shallow copy questions which were weird because we also never went over that stuff.

Then I kept finding typos all over the place which changed the answer to the question, so I never really knew if she made a typo on purpose or by accident so I kept having to call her over to check.

TIL i much, much prefer a practical test than a multiple choice test for programming. **** multiple choice.
I'd think this too but I've been on the other side grading exams full of coding problems and that sucks for everyone too.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 02:45 AM
Quote:
Originally Posted by candybar
Correct on both.



The former is a legal method but not a constructor. So depending on the wording, your answer may be correct or not.
Ah then I probably got that one wrong. I figured "void" was extraneous but technically legal. Overthought it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 03:09 AM
Yea, there can be more than one constructor, but it will always be public ObjectName(), public ObjectName(param1, param2...param n), etc
with no return type, not even void.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 04:43 AM
Quote:
Originally Posted by jmakinmecrzy
here's an example:



How many objects are created here? (I put 1)

is bc a deep copy or a shallow copy? (I put shallow. this wasn't how the question was worded and i may be remembering it wrong)

then a question about constructors that basically showed 2 examples of code, one where the constructor was public void, and the other where it was just public. it asked which one was legal, and I put both are legal. Correct?
Quote:
Originally Posted by candybar
Correct on both.
Maybe I misunderstand, but I don't see any copying being done at all. Don't ab and bc both refer to the same object in memory?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 10:27 AM
Yeah in Java that's a pointer. http://stackoverflow.com/questions/8...object-in-java
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 11:52 AM
Quote:
Originally Posted by gaming_mouse
Maybe I misunderstand, but I don't see any copying being done at all. Don't ab and bc both refer to the same object in memory?
This is one of those questions where you can either give them the answer they want or spend a ton of energy arguing that the question is flawed.

Both have pros and cons.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 11:55 AM
Yay, the site I am working for is done. I billed ~110 hours in the last two weeks (which is too much coding).

I do have a question for anyone who might have more DB experience than me. We have a staging server, where we have been testing a massive change to the codebase (we have been redoing the site for about 6 weeks, not updating the main site at all). On the staging server we populated a bunch of tables with data for when we push to the main site.

I need to take those ~6 tables, get a dump of them, then once I migrate the databases on production, literally force those exact tables onto the production database (just overwrite the tables with the dumps, same IDs and everything). Is this easy? We are using heroku.

Also, if anyone is using a chat program at the office, this company kato.im has a really sick product (not my site, just really enjoy their product). It's way better than hipchat or other options as best I can tell. They were techstars Boulder last summer, and it's awesome. I guess they wrote it in erlang and knockout, but it's screaming fast and fun to use. I hated hipchat and am on this thing all the time.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 12:59 PM
That's a great thread suzzer and thanks for clarifying the concept for me. I swear we never learned it, and it just showed up on the final.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:10 PM
Quote:
Originally Posted by jmakinmecrzy
That's a great thread suzzer and thanks for clarifying the concept for me. I swear we never learned it, and it just showed up on the final.
I have no idea about your specific case, but when I was a TA it was super standard to have students come up after an exam bitching about questions that they were never taught the answer to. I'd say the breakdown was something like (obviously straight out of my ass):

50% - It was directly covered in at least 2 of lectures, tutorials, or assignments.
25% - It was a concept that built upon a simpler concept that was covered and it was just a harder question to see if people really understood the material.
20% - One of the 4 or 5 profs teaching the course didn't cover it and sort-of screwed their specific students.
5% - Legitimately not covered and kind of an unfair question.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:16 PM
Quote:
Originally Posted by jjshabado
This is one of those questions where you can either give them the answer they want or spend a ton of energy arguing that the question is flawed.

Both have pros and cons.
that is a pretty massive flaw, though.

from everything he's said about the class so far, it sounds like a pretty harmful introduction to both java and programming in general.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:17 PM
Quote:
Originally Posted by jjshabado
I have no idea about your specific case, but when I was a TA it was super standard to have students come up after an exam bitching about questions that they were never taught the answer to. I'd say the breakdown was something like (obviously straight out of my ass):

50% - It was directly covered in at least 2 of lectures, tutorials, or assignments.
25% - It was a concept that built upon a simpler concept that was covered and it was just a harder question to see if people really understood the material.
20% - One of the 4 or 5 profs teaching the course didn't cover it and sort-of screwed their specific students.
5% - Legitimately not covered and kind of an unfair question.
25% - It was a concept that built upon a simpler concept that was covered and it was just a harder question to see if people really understood the material.

Probably that - we definitely learned the concept, I just don't ever remember going over specific terminology. She probably expected us to read our books, which I did fortunately. Her lectures were a joke, she'd skim through power point slides rapid pace and then we'd do an in class lab. Basically most of what we learned was from our labs. She even told us she had no experience with java.

I feel bad for the class. I got an 83 and there was only 1 kid who scored higher than that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:20 PM
Quote:
Originally Posted by gaming_mouse
Maybe I misunderstand, but I don't see any copying being done at all. Don't ab and bc both refer to the same object in memory?
Quote:
Originally Posted by suzzer99
You guys are correct; with shallow copy and deep copy being given as the only choices, I just assumed that by shallow copy, they meant copying the reference. If there was a "neither" third option, that's correct, since shallow copying usually implies at least one-level deep field-by-field copying.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:27 PM
I'll try to find the specific question, but I remember there being 2 other nonsense choices and then deep/shallow copy.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:36 PM
Quote:
Originally Posted by jmakinmecrzy
I'll try to find the specific question, but I remember there being 2 other nonsense choices and then deep/shallow copy.
If one of the nonsense choices mentioned something about pointers or references or not copying, it's probably correct.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:46 PM
It was a 3 hour test and i was kind of wiped out by the end of it so that's entirely possible. Lolme. Thanks
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 01:48 PM
This is potentially a really really dumb question and something i really should know. Say if we doing a simple search to find a name on a list and get a label from that name. sooo John - 2 would return 2. This is O(n).If the labels were out of 6, and we copied all the names which had label 1, 3, 4, 5, 6 into another file and then searched if john existed and if it didnt exist, return 2, which is also O(n). Which one is better? i assume its the first? as best case is 1 and average case is n/2 and the latter one best case is n, and average case is n?

Last edited by Burnss; 12-11-2013 at 01:50 PM. Reason: and ye, i know theres more efficeient search algerithms than O(n)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 04:30 PM
Nchabazam,

I don't know about your exact situation but since you're using Heroku you're probably using postgres?

If you run this on an empty table:

Code:
ActiveRecord::Base.connection.reset_pk_sequence!("posts")
It will reset the ID counter for a "posts" table if it happened to exist. Might come in handy if you need to dump/migrate/insert some data.

SO always says you can just do:

Code:
Post.create({ id: 123 }, without_protection: true)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 05:53 PM
So I'm 4th in line on the wait list for Java 1 class at local junior college. Capacity is currently at 30 and first day is mid-January. What are my odds of 4 people dropping by that time????
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 07:00 PM
Quote:
Originally Posted by Shoe Lace
Nchabazam,

I don't know about your exact situation but since you're using Heroku you're probably using postgres?

If you run this on an empty table:

Code:
ActiveRecord::Base.connection.reset_pk_sequence!("posts")
It will reset the ID counter for a "posts" table if it happened to exist. Might come in handy if you need to dump/migrate/insert some data.

SO always says you can just do:

Code:
Post.create({ id: 123 }, without_protection: true)
ya the without_protection seems like the ticket. I need to preserve the IDs that are in the tables because there are a few join tables, so the IDs need to match up.

I can just run a script to create all the same objects forcing the ID on them, shouldn't be a problem.

Thanks.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 08:58 PM
Quote:
Originally Posted by Barrin6
So I'm 4th in line on the wait list for Java 1 class at local junior college. Capacity is currently at 30 and first day is mid-January. What are my odds of 4 people dropping by that time????
Probably pretty high. Worst case scenario, check the online signup tool every day (assuming there is one) and go to the first day of class even if you're not in by then. Professors often have a few discretionary slots on this stuff.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 09:49 PM
Yeah, I'd guess at least a few people would drop that course within the first week.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-11-2013 , 11:10 PM
Someone came into work for an interview today. The hiring manager showed me the resume before he came in and said it was unlikely the guy would bother considering his splash of technologies listed on it, including HTML 3, PHP 4, C/C++, and of course, SQL.

I told the hiring manager that I wasn't particularly impressed for several reasons. The guy comes in, the HM fires up the database and asked me to give him a basic SQL test to see how we would do. After a brief introduction where he told me about building sites from scratch...

The questions were:

1- Select all the items from this table.

SELECT * FROM "MY_TABLE";

2- Write a query that tells me how many rows are in the table.

SELECT * FROM MY_TABLE -- I corrected him on the first but perhaps that is syntax...
--- minute passes. I tell him he can use Google if he wants.

SELECT * FROM MY_TABLE
WHERE ROW --- Give up.

3- See that first row there? Write a query that only shows that row.

-- "I don't know how."

Final score: 0
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

      
m