Practice 2
Practice problems on Classes and Objects
Due date: Sat, March 4th at 10:00pm
Sign in to Google to save your progress. Learn more
Name *
ID *
Section *
Questions
Q 1:
class A
{
    public A(int i)
   {
        System.out.print(1+ " ");
    }
 
    public A()
    {
        System.out.print(2+ " ");
    }
 
    public static void main(String[] args)
    {
        System.out.print(3+ " ");
 
        A a = new A();
    }
}
Based on the code above,  What will be the output? *
Q 2:
public class A
{
    private A()
    {
        System.out.println("It is a constructor");
    }
}
Based on the code above,  can you create objects of type A? *
Q 3:
Answer the following questions:
Can you define  a constructor without a body? *
What is the difference between No-arg constructor and default constructor? *
Q 4:
public class A
{    
public static void methodOne()
    {
 char a = 'A';
        System.out.print(a+" ");
    }
 
    public static void methodTwo()
    {
    char b = 'B';
    System.out.print(b+" ");
        methodOne();
    }
 
    public static void main(String[] args)
    {
    char c = 'C';
    System.out.print(c+" ");
        methodTwo();
    }
}
// thanks for HAYA :)
Is the above code written correctly? If yes, what will be the output? If no, why?
Clear selection
Q 5:
For the following class UML diagrams,
1.
Write the correspondent Java class
2.
Write the correspondent Java class
3.
Write the correspondent Java class
4.
Write the correspondent Java classes
How do you rate this practice set
I think
Clear selection
Submit
Clear form
Never submit passwords through Google Forms.
This content is neither created nor endorsed by Google.