Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3216374
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:17:13+00:00 2026-05-17T15:17:13+00:00

Example 1 /** *Program Name: Cis36L0411.java *Discussion: Class — Data Members ONLY * Method

  • 0

Example 1

/**
 *Program Name: Cis36L0411.java  
 *Discussion:   Class -- Data Members ONLY
 *                       Method Members ONLY
 */ 
class Cis36L0411 
{
  public static void main( String[] args )
  {
    DataOnly data1 = new DataOnly();        

    System.out.println( "DataOnly\tLIMIT\t\t" + data1.LIMIT );
    System.out.println( "\t\tintMem\t\t" + data1.iMem );
    System.out.println( "\t\tdoubleMem\t" + data1.dMem );

    MethodOnly method1 = new MethodOnly();  

    method1.printFunc( 5 );
    method1.printFunc( "MethodOnly object!" );

    method1.printFunc( data1.LIMIT );

    return;
 }
}

class DataOnly
{
  final int LIMIT = 100; //constant and package mode or access
  int iMem;              //package mode or access
  double dMem;           //package mode or access
}

class MethodOnly
{
  void printFunc( int iA ) //package mode or access
  {
    System.out.println( "The int value is " + iA );

    return;
  }

  public void printFunc( String str ) //public mode or access
  {
   System.out.println( "The String is printed from  " + str );

    return;
  }
}

I went to this site and I read it, but I am still confused.

  1. DataOnly data1 = new DataOnly(); I know this line creates an object. But can someone break this line down for me? What does each word do? DataOnly is the class? type? data1 is the variable? I think new DataOnly is a reference to a location. And the () is the variables in the location? Am I correct?

  2. How did they print data1.LIMIT, data1.iMem, Data1.dMem? Did they print it by looking at the location of DataOnly()? Does DataOnly() reference class DataOnly?

  3. I’m just completely lost on the whole process of the MethodOnly object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:17:13+00:00Added an answer on May 17, 2026 at 3:17 pm

    1) DataOnly data1 = new DataOnly(); I
    know this line creates an object. But
    can someone break this line down for
    me? What does each word do? DataOnly
    is the class?type? Data1 is the
    variable? I think new DataOnly is a
    reference to a location. And the () is
    the variables in the location? Am I
    correct?

    The line means create a variable named “data1” of the type DataOnly. Then create a new object of type “DataOnly” and make the variable point to it.

    2) How did they print data1.LIMIT,
    data1.iMem, Data1.dMem? Did they print
    it by looking at the location of
    DataOnly()? Does DataOnly() reference
    class DataOnly?

    DataOnly is just the template for an object (a class). The print is using an object in memory created from that template to print the values.

    3) I’m just completely lost on the
    whole process of the MethodOnly
    object.

    Objects can contain both data and perform functions depending on the tempate (class) it was created from. The MethodOnly class appears to be defined to only contain code and no data. The DataOnly class seems to be defined to just store values and not do any actions.

    Summary
    I think the easiest way to think of it is that the class is the blue-print for an object. Objects are created (using the “new” keyword) based on these blueprints and stored in memory. So all your work will be done with objects, you just use the classes to tell it what type of object you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I've got the following program: namespace ReflectionTest { public class Example { private
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I want to test a program's memory management capabilities, for example (say, program name
I'm not sure how to name data store classes when designing a program's data
The example program below compiles two in-memory assemblies. The first compilation works fine. The
Dev-cpp comes with an example program Jackpot, which has a GetResults function in it:
I'm trying to compile the following simple DL library example code from Program-Library-HOWTO with
I know how to program Console application with parameters, example : myProgram.exe param1 param2.
I want to escape '' and all other wild chars in program name and
I have a java program that connects to a MySql database and it's working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.