Menu
Question Index
...

Define a Mobile class with member variables model, numberOfSims, memory and hasCamera. There respective data types are String, int, double and boolean.



class MobileTester
{
    public static void main(String s[])
    {
        Mobile mobile = new Mobile();
        mobile.model = "Nokia 2430";
        mobile.numberOfSims = 1;
        mobile.memory = 512.0;
        mobile.hasCamera = false;
        
        System.out.print(mobile.model + " has " + mobile.numberOfSims + " sims and has a memory of " + mobile.memory + " MB.");
        System.out.println(mobile.hasCamera ? " It has a camera." : " It has no camera.");

    }



}
class Mobile
{
}

Doubts

Problems

Topic: Member Variable In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App