EMC Interview Question Software Engineer in Tests

  • emc-interview-questions
    0
    of 0 votes
    7
    Answers

    Write o/p of following program

    Class A
    {
    public static void main(String[] s)
    {
    System.out.println("Hello");
    }
    public static void main()
    {
    System.out.println("Hello");
    }
    public static void main (int args[])
    {
    System.out.println("Hello");
    }
    }

    - panshul21 on June 02, 2012 in India for RSA Report Duplicate | Flag
    EMC Software Engineer in Test

Team: RSA
Country: India
Interview Type: Written Test


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

First of all this class has to be public. Assuming this class is public class A. It will call the first method with arguments String[] and print Hello. The rest two methods will not be executed.

- dharmendra on June 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

But what will be the answer if the first function whose argument is string args[] is the third function ??

- Pranay Singhania on June 03, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

:) The order of the function doesn't matter. If there is a main function with signature public static void main (String []args) in a public class. No matter where it appears in the lexicographic order in the code. That is the first function to be invoked by the JVM.

Moreover if you see two main functions with this signature then you are in trouble, It must give a compilation error saying duplicate methods.

- dharmendra on June 03, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here JVM understands only the main method that has String type as its arguments, as the data read from the console is always in character format and the other methods does not have any calls in the main(String args[]).So not possible to execute the remaining methods .the out put is just hello

- balaji on June 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

System.out.println("Hello");

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

only the public static void main(String[] s) shoud be ran

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

JVM always looks out for public static void main(String[] args) syntax to begin a program with. The order of the functions doesn;t really matter.

Well, in this particular code, the answer will be Hello, because all of them print the same thing :P.

- Srirang on June 05, 2012 | Flag Reply


Add a Comment
Name:

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

Books

is a comprehensive book walking you through 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