UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

if we create a main method in a static nested class then run a program by the command Outerclass$Innerclass why?

Asked by Last Modified  

3 Answers

Learn Java

Follow 0
Answer

Please enter your answer

The static variable can be used to refer the common property of all objects (that is not unique for each object) e.g. company name of employees,college name of students etc. The static variable gets memory only once in class area at the time of class loading.
Comments

Trainer

What is interesting here is that when we compile a file that contains an inner class, we actually end up with two class files and not one. Because of the fact that the inner class is technically a separate class, a separate class file will be created for it as well -- which can see with the “OuterClass$InnerClass.class”...
read more
What is interesting here is that when we compile a file that contains an inner class, we actually end up with two class files and not one. Because of the fact that the inner class is technically a separate class, a separate class file will be created for it as well – which can see with the “OuterClass$InnerClass.class” class file. The dollar sign is used to separate the inner class name from the outer class name. But, we will not be allowed to run the command above, because an inner class can not have any static members at all – and that includes “public static void main()”. This is because we would not be able to access the instance variables of the outer class from within a static context of the inner class. And, if there were a static method inside the “inner class” it wouldn’t even be an inner class – it would technically have to be declared with the static modifier and therefore it would be a static nested class. So, this means that the only way that we can access an inner class is by creating an actual instance of the outer class. And this also means that we can only access the inner class at runtime when we already have an instance of the outer class that we can use to access the inner class. read less
Comments

Professional Tutor with 15 years of experience.

After compilation the CLASSfile for inner class iis Outerclass$Innerclass
Comments

View 1 more Answers

Related Questions

Why we are using this keyword in Java?
"this" keyword is use to refer an object of current class it is also use for call specific constructor of current class if more than one constructor is declared.
Kiran
0 0
9
Is it really needed to do Java training before graduation, to get a job?
Yes, It's must to get better opportunities and to standard alone in IT field. Not only core Java but also learn Spring,Hinernat ,Struts. ANGULARJS add an advantage to get job easily.
Udaybhan
What is a singleton class and when do you use it?
Singleton class have a private constructor. while we can't create an object from outside of class, we can create an object only once.
Prakash
What are the qualities of a good Java trainer?
Good java trainers are always teaching their students with practical examples. This exactly happens in BEE Apprentice, our trainers are working in MNCs hence they are updated with technology and are best trainers.
Venu
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

jOOQ 3.10 Supports JPA Attribute Converter
One of the cooler hidden features in jOOQ is the JPADatabase, which allows for reverse engineering a pre-existing set of JPA-annotated entities to generate jOOQ code. For instance, you could write these...

Easy way to remember Java keyword.
ACCESS MODIFIER ACCESS SPECIFIER abstract, assert, const, final, native, static, strictfp, super, synchronized, this, transient, void, volatile public, private, protected, default DATA...

Rohit Deshbhratar

1 0
0

Java: A Quick Overview
Not purely Object Oriented: It doesn't support multiple inheritence, it supports primitive data types and static members. Doesn’t support multiple inheritance: Reason is diamond problem i.e.,...

10 Cool SQL Optimizations That Do Not Depend On The Cost Model
Today, we don’t want to talk about cost based optimisation, i.e. optimisations that depend on a database’s cost model. We’ll look into much simpler optimisations that can be implemented...

Advance Java
1) Servlet • Basics of Servlet • Servlet Request • Servlet Collaboration • Servlet Config • Servlet Context • Attribute • Session Tracking • Event and Listener •...
A

Recommended Articles

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more