import interview questions
Top import frequently asked interview questions
In Python you can do a:
from a import b as c
How would you do this in Java, as I have two imports that are clashing.
Source: (StackOverflow)
Is there any good reason to avoid unused import statements in Java? As I understand it, they are there for the compiler, so lots of unused imports won't have any impacts on the compiled code. Is it just to reduce clutter and to avoid naming conflicts down the line?
(I ask because Eclipse gives a warning about unused imports, which is kind of annoying when I'm developing code because I don't want to remove the imports until I'm pretty sure I'm done designing the class.)
Source: (StackOverflow)
I'm learning some CSS to tweak my project template. I come to this problem and didn't find a clear answer on the web. Is there a difference between using @import or link in CSS?
Use of @import
<style type=”text/css”>@import url(Path To stylesheet.css)</style>
Use of Link
<link rel=”stylesheet” type=”text/css” rel='nofollow' href=“Path To stylesheet.css” />
What's the best way to do it? and why?
Thanks!
Edit: There is some thoughts here
Source: (StackOverflow)
I'm wondering what decides whether you're allowed to use <Header.h>
or "Header.h"
when you're importing files in Objective-C. So far my observation has been that you use the quote marks ""
for files in your project that you've got the implementation source to, and angle brackets <>
when you're referencing a library or framework.
But how exactly does that work? What would I have to do to get my own classes to use the brackets? Right now Xcode will not allow me to do that for my own headers.
Also, by looking in some frameworks headers, I see that the headers reference each other with <frameworkname/file.h>
. How does that work? It looks a lot like packages in Java, but as far as I know, there is no such thing as a package in Objective-C.
Source: (StackOverflow)
I am using PostgreSQL 8.4, and I have some *.sql files to import into a database. How can I do so?
Source: (StackOverflow)
How can you reliably and dynamically load a JavaScript file? This will can be used to implement a module or component that when 'initialized' the component will dynamically load all needed JavaScript library scripts on demand.
The client that uses the component isn't required to load all the library script files (and manually insert <script>
tags into their web page) that implement this component - just the 'main' component script file.
How do mainstream JavaScript libraries accomplish this (Prototype, jQuery, etc)? Do these tools merge multiple JavaScript files into a single redistributable 'build' version of a script file? Or do they do any dynamic loading of ancillary 'library' scripts?
An addition to this question: is there a way to handle the event after a dynamically included JavaScript file is loaded? Prototype has document.observe
for document-wide events. Example:
document.observe("dom:loaded", function() {
// initially hide all containers for tab content
$$('div.tabcontent').invoke('hide');
});
What are the available events for a script element?
Source: (StackOverflow)
This question already has an answer here:
I'm wondering if there's any difference between the code fragment
from urllib import request
and the fragment
import urllib.request
or if they are interchangeable. If they are interchangeable, which is the "standard"/"preferred" syntax (if there is one)?
Thanks!
Source: (StackOverflow)
I would like to import data from a CSV file into an existing database table. I do not want to save the CSV file, just take the data from it and put it into the existing table. I am using Ruby 1.9.2 and Rails 3.
This is my table:
create_table "mouldings", :force => true do |t|
t.string "suppliers_code"
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
t.integer "supplier_id"
t.decimal "length", :precision => 3, :scale => 2
t.decimal "cost", :precision => 4, :scale => 2
t.integer "width"
t.integer "depth"
end
Can you give me some code to show me the best way to do this, thanks.
Source: (StackOverflow)
Can you import .css files into .less files...?
I'm pretty familiar with less and use it for all my development. I regularly use a structure as follows:
@import "normalize";
//styles here
@import "mixins";
@import "media-queries";
@import "print";
All imports are other .less files and all works as it should.
My current issue is this:
I want to import a .css file into .less that references styles used in the .css file as follows:
@import "../style.css";
.small {
font-size:60%;
.type;
}
// other styles here
The .css file contains a class called .type
but when I try to compile the .less file I get the error NameError: .type is undefined
Will the .less file not import .css files, only other .less ones...? Or am I referencing it wrong...?!
Source: (StackOverflow)
I have very large tables (30 million rows) that I would like to load as a dataframes in R. read.table()
has a lot of convenient features, but it seems like there is a lot of logic in the implementation that would slow things down. In my case, I am assuming I know the types of the columns ahead of time, the table does not contain any column headers or row names, and does not have any pathological characters that I have to worry about.
I know that reading in a table as a list using scan()
can be quite fast, e.g.:
datalist <- scan('myfile',sep='\t',list(url='',popularity=0,mintime=0,maxtime=0)))
But some of my attempts to convert this to a dataframe appear to decrease the performance of the above by a factor of 6:
df <- as.data.frame(scan('myfile',sep='\t',list(url='',popularity=0,mintime=0,maxtime=0))))
Is there a better way of doing this? Or quite possibly completely different approach to the problem?
Source: (StackOverflow)
I am trying to "import existing project into workspace". As the "root directory" I select the directory where all my .java (and .class) files are located. Eclipse writes me that "no projects are found to import". Why?
Source: (StackOverflow)
Trying to import a CSV with contact information:
Name,Address,City,State,ZIP
Jane Doe,123 Main St,Whereverville,CA,90210
John Doe,555 Broadway Ave,New York,NY,10010
Running this doesn't seem to add any documents to the database:
$ mongoimport -d mydb -c things --type csv --file locations.csv --headerline
Trace says imported 1 objects
, but firing up the Mongo shell and running db.things.find()
doesn't show any new documents.
What am I missing?
Source: (StackOverflow)
I thought this would be trivial, but it isn't... I'm sure there is a simple way to do it but I can't manage to find it. Shame on me.
I want to import/export the database itself, the tables, the constraints (foreign keys and so on). I'd rather not get the data with it, but I can get rid of it after if there's no other way.
So... how do you export a database using MS SQL Server Management Studio ? How do you import it?
The only solution I found was right click on the tables and "script to Create", but I have something like 100 tables, so I'd rather avoid this.
Thanks!
Source: (StackOverflow)
I am playing around with some of the new iOS 7 features and working with some of the Image Effects as discussed in the WWDC video "Implementing Engaging UI on iOS". For producing a blur effect within the source code for the session, UIImage
was extended via a category which imports UIKit like so:
@import UIKit;
I think I saw something about this in another session video but I'm having trouble finding it. I'm looking for any background information on when to use this. Can it only be used with Apple frameworks? Are the benefits of using this complier directive enough that I should go back and update old code?
Source: (StackOverflow)