IndiaBIX
IndiaBIX
Start typing & press "Enter" or "ESC" to close
  • Home
  • Jobs
  • Results
  • Current Affairs
  • GK
  • Online Test
  • HR Interview
  • BLOG

public class Outer { public void someOuterMethod() { //Line 5 } public class Inner { } public static void main(String argv) { Outer ot = new Outer(); //Line 10 } } Which of the following code fragments inserted, will allow to c

  • Home
  • Computer Science & Engineering
  • Java Programming Questions and Answers
  • Declarations and Access Control - General Questions
  • Discuss - 1367
1. 

public class Outer
{
public void someOuterMethod()
{
//Line 5
}
public class Inner { }

public static void main(String[] argv)
{
Outer ot = new Outer();
//Line 10
}
}

Which of the following code fragments inserted, will allow to compile?

[A]. new Inner(); //At line 5
[B]. new Inner(); //At line 10
[C]. new ot.Inner(); //At line 10
[D]. new Outer.Inner(); //At line 10

Answer: Option A

Explanation:

Option A compiles without problem.

Option B gives error - non-static variable cannot be referenced from a static context.

Option C package ot does not exist.

Option D gives error - non-static variable cannot be referenced from a static context.

Workspace Report
Leave a Comment

Computer Science & Engineering :: Java Programming Questions and Answers : More Exercises

  • Language Fundamentals - General Questions
  • Operators and Assignments - Finding the output
  • Exceptions - Finding the output
  • Inner Classes - General Questions
  • Height and Distance - Garbage Collections
  • Java.lang Class - General Questions
  • Declarations and Access Control - General Questions
  • Flow Control - General Questions
  • Objects and Collections - General Questions
  • Threads - General Questions
  • Assertions - Finding the output

Questions & Answers

Aptitude Chemical Engineering Civil Engineering Computer Science & Engineering Current Affairs Data Interpretation Electrical & Electronics Engineering Electronics & Communication Engineering General Knowledge Logical Reasoning Mechanical Engineering Non Verbal Reasoning Verbal Ability Verbal Reasoning

Interviews

HR Interview

Jobs

Sarkari Jobs

Results

Rojgar ResultSarkari Result

Admission

Admission 2023

Admit Card

Admit Card 2023

Answer Key

Answer Key 2023
copyright
Privacy Policy
© 2025 IndiaBIX. All Rights Reserved.

Report