ION idea Interview Question for Developer Program Engineers


Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
2
of 2 vote

Such a program is called as quine. For more information google with the keyword "quine".

- slater May 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

this is the code that can print its source code as its output in java
import java.io.*
class Source
{
public static void main(String args[]) throws Exception
{
FileReader fr=new FileReader("Source.java");
BufferedReader br=new BufferedReader(fr);
String str=null;
while((str=br.readLine())!=null)
System.out.println(str);
}
}

- balaji May 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

The goal of this question could have been to check if you are aware of this marvelous piece of work. Its a must read for all in this field.

Look up paper titled Reflections of Trusting Trust by ken thompson!

- keshi May 30, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

this 1 from wiki:

public class Quine
{
  public static void main( String[] args )
  {
    char q = 34;      // Quotation mark character
    String[] l = {    // Array of source code
    "public class Quine",
    "{",
    "  public static void main( String[] args )",
    "  {",
    "    char q = 34;      // Quotation mark character",
    "    String[] l = {    // Array of source code",
    "    ",
    "    };",
    "    for( int i = 0; i < 6; i++ )           // Print opening code",
    "        System.out.println( l[i] );",
    "    for( int i = 0; i < l.length; i++ )    // Print string array",
    "        System.out.println( l[6] + q + l[i] + q + ',' );",
    "    for( int i = 7; i < l.length; i++ )    // Print this code",
    "        System.out.println( l[i] );",
    "  }",
    "}",
    };
    for( int i = 0; i < 6; i++ )           // Print opening code
        System.out.println( l[i] );
    for( int i = 0; i < l.length; i++ )    // Print string array
        System.out.println( l[6] + q + l[i] + q + ',' );
    for( int i = 7; i < l.length; i++ )    // Print this code
        System.out.println( l[i] );
  }
}

- salvo4u May 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

but i doubt such programs will be asked from u in interviews

- salvo4u May 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

That shouldnt matter at all
Just distribute the .class file

- salvo4u May 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

hi praveen,
it is a interview question that says we have the source code with us and try to print it .

- balaji May 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Way too easy in C/C++,

use to do in my early programming days.. :)..

M nt sure its wat they expected but I will read a file whose file name is the program's File name . :)

- Prem May 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

please tell me the the code!

- sameer March 22, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can use below line in code..It'll work in Linux

system("vi filename.c");

- laki.sreekanth May 30, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/perl -w
my $fileName = $0;
open(FILE, $fileName);
while(<FILE>){
    print $_;
}
close(FILE);

- Anonymous June 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It is the simplest:

int main()
{
        char *s="int main(){char *s=%c%s%c;printf(s,34,s,34)}";
        printf(s,34,s,34);
}

see here:ideone.com/iZvI3

- Aashish July 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

In simplest terms, I am thinking of writing a program which opens its source code file ( with file handling) and reads it and subsequently writes the output.

- Mad Coder May 28, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More