View the step-by-step solution to:

Question

Please help me answer these questions, I need this for my quiz. Thank You!


TRUE OR

FALSE:

  1. Any method declared and defined inside a class can call each other.
  2. new operator can only be used in declaring a class method.
  3. Constructors must be declared as private.
  4. Hiding of internal structure from the surroundings is an abstraction of object.
  5. To convert the string to lowercase letters tolower() method will be used.
  6. A java application program only run inside a web browser or using Appletviewer.
  7. Java Virtual Machine (JVM) provides machine dependency.
  8. indexOf() method determines the specific character in a string.
  9. Stringreplace() method changes the occurrence of certain character in the string.
  10. To incorporate a package in a Java program, an include expression will be used.
  11. An individual array element that is passed to a method and modified in that method will contain the modified value when the called method completes execution.
  12. The arguments that you send to a method must match in both number and type in the parameter that is listed in the method header.
  13. Instance methods are directly invoked within the class where it has been defined by calling a method name or it called by another class by calling the classname followed by a dot then the method name.
  14. Private access is sometimes called information hiding and is an important component of object-oriented programming.
  15. Public classes are accessible by all objects, which means that public classes can be extended or used as a basis for any other class.
  16. A class is just an abstract of what an object will be like if any objects are actually instantiated.
  17. charAt() method determines the position of a character in a string.

Multiple Choice. Write the letter of the correct answer before the number.

1.The method public static boolean testvalue(int sagot) returns

a. boolean             b. void                         c. int                d. undefined

2. A variable declaration always contains two components: data type and its ______.

a. value            b. initial value                   c. name           d. terminator

3.Classes, objects and methods are separated by _____

a. comma        b. underscore                    c. semi-colon              d. period

4.A method that establishes an object.

a. main()          b. init()                   c. constructor              d. class

5.Objects inherit attributes from _________

a. object itself        b. classes        c. methods      d. no answer

6.Once a java program compiled, another file is created with an extension named ___.

a. .class                 b. .obj              c. . exe                        d. .javac

7.The hardware or software environment in which a program runs.

a. package            b. platform       c. desktop                   d. operating system

8.Instance method header/definition contains the following except _______.

a. method name    b. access modifier      c. return type               d. expressions

9.Mostly used as garbage collector.

a. Constructor                   b. Destructor               c. Method        d. Class

10.A method that has the same name but different in return type and/or parameters.

a. Overloading      b. Overriding               c. Instance      d. Constructor

11.Feature of OOP that all acquiring all the characteristics of the object parent.

a. Polymorphism   b. Inheritance              c. Abstraction              d. Encapsulation


12.It defines in terms of what objects perform and not how they perform.

a. Polymorphism   b. Inheritance              c. Abstraction  d. Encapsulation

13.It secures the properties and implementation of the particular object.

a. Polymorphism   b. Inheritance              c. Abstraction              d. Encapsulation

14.The implementation can be implemented in different classes.

a. Inheritance                    b. Encapsulation         c. Polymorphism         d. Abstraction

15.It returns the size of the string.

a. indexOf()                       b. length()                    c. charAt()                   d. sizeOf()

16.Determines the specific character at the given position.

a. charAt()             b. sizeOf()                   c. length()                    d. indexOf()

17.Determines the position of the specific character from the string.

a. indexOf()           b. charAt()                   c. sizeOf()                   d. length()

18.The elements of an array are related by the fact that they have the same name and _

a. size                    b. type                         c. index           d. subscript

19.Choose the valid identifiers from the following:

a. BigAndLongStringWithNonSenseName           b.  $long          c. double         d. _18

20.Method declaration/definition must include all of the following except:

a. header               b. a call to another method     c. curly braces                        d. body

21.Which statement below is not true about a class method?

it may or may not have a return value or argument

it can be overloaded

it must not be static

it can be accessed from other class

22.What will happen if you run a java program like this: c:> java Test naruto (assuming the class name is Test)

there will be an error because of the inclusion of "naruto"

the program will execute properly provided there is a string to hold "naruto" in the program

the program will still run even if there is no string variable to hold "naruto" in the program

the syntax to run java is wrong

23.How will a class method named method1 created from a class Cls1 be called from another class named Cls2?

                  a. Cls2.method1();            b. method1();  c. Cls1.method1();      d.Cls2. Cls1.method1();

24.If a method accepts an array of integers, which statement below is the proper way of calling that method?

method_name(array_name);                   b. method_name(array_name[ ]);

c.   method_name(array_name());                 d. method_name(int array_name);

25.A method with a header as public static boolean x (int y) accepts what type of value?

a.  boolean            b. integer         c. void             d. static

26.Consider the line of code:             int [ ] x = new int [10];

After execution, which statement is true?

a. x[9]                b. x.length() is 10                    c. x[10] is 0      d. x[0] is null

27,Consider the following application:

public class Class

{ public static void main(String [ ] args)

   {  Other o = new Other();

       o.x = 51;

       System.out.println(o.getX());

} }

public class Other

{   public int x;

    public int getX()

     {  x++; return x; }

}

What is the output after you compiled and run the program?

a. The program will run and the output is 51

b. The program will run and the output is 52

c. The program will compile but there is no output

d. The program will not compile and an exception is thrown


28 - 30:   Analyze the two classes below:


public class SideA

{ public static void main(String args[ ])

  { int , y;

    y = Doble(x);

    System.out.println(y);

   }

  public static int Doble(int a)

   { return a*a; }

  public static int is_odd(int a)

  { if (a%2=) return 0;

    else return 1; }

}

public class SideB extends SideA

{

public static void main(String args[ ])

  {  int , b;

     b = Doble(a);

     System.out.println(b);

  }

}

  

28.It is possible for class SideB to access the method is_odd of class SideA?

a. Yes                   b. No               c. Maybe         d. I don't know

29.Will the class SideB execute properly after compilation?

a. No because there is no method Doble() in class SideB

b. Yes because SideB inherited the methods of class SideA

c. No because the method call is wrong.  It should be b = SideA.Doble(a);

d. Yes but there will be no output since the method Doble does not exists

30.Assuming there is a method named Doble is class SideB, and assuming also that class SideB have access to all the methods of class SideA. Which method will be performed when the method call in class SideB is executed?

a. the method Doble of SideB          c. neither

b. the method Doble of SideA          d. there will be an error in compilation

Fill in the blanks:

31-40 Supply the missing keyword(s)/statement(s) on the blank. Write your answer on

         the right.


class GradeClass

{

   double MG, FG;

  

   void setMG(___(31)____)

   {  ____(32)_____ = Mid;  }

  

   public double getMG()

   {  _______(33)_________;  }

  

   void setFG( double Fin)

   {   FG = _____(34)______; }

  

   public _______(35)___________

   {  return (FG); }

}

public class GradeMain

{  public static void main(String args[ ])

    {  ____(36)______ Mid, Fin, Ave;

       GradeClass stud = _____(37)_____;

       _____(38)_____(3.00);

       Stud.setFG(2.75);

       Mid = stud.getMG();

       Fin = _____(39)_______;

       ____(40)___ = (Mid + Fin) / 2;

                  System.out.println ("Average: " + Ave);  

                } 

           }

Top Answer

1) True (but static method will call only static method) 2) False 3) false 4) true 5) false (toLowerCase()) 6) false... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question