Object Oriented Programming (Cs504d)

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Sanjayc
S
Sanjayc
Community Contributor
Quizzes Created: 1 | Total Attempts: 215
Questions: 20 | Attempts: 215

SettingsSettingsSettings
Object Oriented Programming (Cs504d) - Quiz

Questions and Answers
  • 1. 

    Which is a reserved word in the Java programming language? 

    • A.

      Method

    • B.

      Array

    • C.

      Reference

    • D.

      Native

    Correct Answer
    D. Native
    Explanation
    "native" is a reserved word in the Java programming language. In Java, reserved words are predefined keywords that have specific meanings and cannot be used as identifiers or variable names. The "native" keyword is used to indicate that a method is implemented in a language other than Java, typically in a platform-specific manner.

    Rate this question:

  • 2. 

    From any non-sub-class Class outside the package, which access is possible?

    • A.

      Public

    • B.

      Protected

    • C.

      Default

    • D.

      Private

    Correct Answer
    A. Public
    Explanation
    From any non-sub-class Class outside the package, the access that is possible is public. This means that any class outside the package can access the public members (variables, methods, etc.) of the non-sub-class Class. Public access allows for the widest accessibility and is not restricted to any specific class or package.

    Rate this question:

  • 3. 

    What will be the output if you execute the following java code?     import java.lang.*;      class firstapp        {           static()                {                 System.out.println(“Hello world”);                 }        } 

    • A.

      Hello world

    • B.

      Compilation error

    • C.

      Run time error

    • D.

      Hello world with a warning message

    Correct Answer
    D. Hello world with a warning message
    Explanation
    The code provided is attempting to define a static method in the class "firstapp". However, the method name is missing, which results in a compilation error. The correct syntax for defining a static method is "static void methodName()". Therefore, the correct answer is "Compilation error".

    Rate this question:

  • 4. 

    Public class Test{}    What is the prototype of the default constructor? 

    • A.

      Test()

    • B.

      Test(void)

    • C.

      Public Test()

    • D.

      Public Test(void)

    Correct Answer
    A. Test()
    Explanation
    The prototype of the default constructor for the given class "Test" is "Test()". This is because the default constructor has the same name as the class and does not take any parameters.

    Rate this question:

  • 5. 

    Which will legally declare, construct, and initialize an array?

    • A.

      Int [] mylist={“1”,”2”,”3”};

    • B.

      Int [] mylist=(1,2,3);

    • C.

      Int mylist[][]={4,9,7,0};

    • D.

      Int mylist[]={4,6,9};

    Correct Answer
    D. Int mylist[]={4,6,9};
    Explanation
    The correct answer is "int mylist[]={4,6,9};" because it is the only option that uses the correct syntax to declare, construct, and initialize an array. The other options either use incorrect syntax or do not properly initialize the array.

    Rate this question:

  • 6. 

    Which design model lies behind the concept of object oriented programming?

    • A.

      Top-down design

    • B.

      Bottom-up design

    • C.

      Both of these

    • D.

      None of these

    Correct Answer
    B. Bottom-up design
    Explanation
    The design model that lies behind the concept of object-oriented programming is bottom-up design. This approach involves breaking down a problem into smaller, more manageable components or objects, and then gradually building up the overall solution by combining these objects. It emphasizes starting with the details and gradually constructing the larger system. This contrasts with top-down design, which starts with the overall structure and breaks it down into smaller components.

    Rate this question:

  • 7. 

    Which of the following is an object based language (OBL) ?

    • A.

      Ruby

    • B.

      Delphi

    • C.

      Java Script

    • D.

      Simula

    Correct Answer
    C. Java Script
    Explanation
    JavaScript is an object-based language because it uses objects to represent and manipulate data. It supports object-oriented programming concepts such as inheritance and encapsulation. Objects in JavaScript are instances of classes, and they can have properties and methods. JavaScript also has a prototype-based inheritance model, where objects can inherit properties and methods from other objects. This makes JavaScript a suitable choice for building interactive web applications that require dynamic behavior and manipulation of objects.

    Rate this question:

  • 8. 

    In OOPs which mechanism binds data and function together ?

    • A.

      Modules

    • B.

      Encapsulation

    • C.

      Class

    • D.

      Abstraction

    Correct Answer
    B. Encapsulation
    Explanation
    Encapsulation is the mechanism in Object-Oriented Programming (OOP) that binds data and functions together. It allows the data to be hidden and accessed only through the functions defined within the class. This helps in achieving data abstraction and ensures that the data is accessed and modified in a controlled manner. Encapsulation also provides data security and helps in maintaining the integrity of the object's state.

    Rate this question:

  • 9. 

    The Scanner class defined in which package?

    • A.

      Utility

    • B.

      Applet

    • C.

      Input-output

    • D.

      Language

    Correct Answer
    A. Utility
    Explanation
    The correct answer is utility. The Scanner class is defined in the utility package in Java. This package contains various utility classes and interfaces that provide useful functions for input, output, and other general purposes. The Scanner class specifically is used for reading input from different sources, such as the keyboard or a file.

    Rate this question:

  • 10. 

    Java is pure object oriented programming language because

    • A.

      Java is Platform-independent

    • B.

      Java is both compiled and interpreted

    • C.

      A single line of code cannot go outside from the class

    • D.

      None of the above

    Correct Answer
    C. A single line of code cannot go outside from the class
    Explanation
    Java is considered a pure object-oriented programming language because it enforces the rule that a single line of code cannot go outside of a class. In Java, all code must be written within a class, and objects are created from these classes. This encapsulation ensures that all code is organized and structured within classes, promoting modularity and reusability. Additionally, Java's platform independence and ability to be both compiled and interpreted further solidify its status as a pure object-oriented language.

    Rate this question:

  • 11. 

    In Java >>> operator is called

    • A.

      Left shift

    • B.

      Right shift with zero fill

    • C.

      Right shift

    • D.

      Left shift with zero fill

    Correct Answer
    B. Right shift with zero fill
    Explanation
    The ">>>" operator in Java is known as the right shift with zero fill operator. This operator shifts the bits of a number to the right by a specified number of positions, and fills the leftmost positions with zeros. Unlike the regular right shift operator (>>), the zero fill operator does not preserve the sign bit, meaning that it treats the number as an unsigned value.

    Rate this question:

  • 12. 

    To check which object is of which class, which of the following is used

    • A.

      Sizeof

    • B.

      Comma

    • C.

      Instanceof

    • D.

      None of the above

    Correct Answer
    C. Instanceof
    Explanation
    The keyword "instanceof" is used to check if an object is an instance of a particular class or implements a specific interface. It returns true if the object is an instance of the class or a subclass of it, or if it implements the interface. In this case, "instanceof" is the correct answer because it is specifically used for determining the class of an object. The other options, sizeof and comma, are not related to checking the class of an object.

    Rate this question:

  • 13. 

    Which conditional statement always returns true value?

    • A.

      If(a==1)

    • B.

      If(a=0)

    • C.

      If(a=1)

    • D.

      If(1==a)

    Correct Answer
    B. If(a=0)
    Explanation
    The correct answer is "if(a=0)". This is because the single equals sign (=) is an assignment operator, not a comparison operator. Therefore, the statement "if(a=0)" will always assign the value 0 to the variable "a" and then evaluate the result as true.

    Rate this question:

  • 14. 

    Array subscript in Java always starts at

    • A.

      -1

    • B.

      1

    • C.

      0

    • D.

      Any value

    Correct Answer
    B. 1
    Explanation
    In Java, array subscripts always start at 0. This means that the first element of an array is accessed using the subscript 0. Therefore, the correct answer is 0.

    Rate this question:

  • 15. 

    This reference is built-in reference can only used within

    • A.

      Static function of the class

    • B.

      Non-static function of the class

    • C.

      Cannot be used

    • D.

      None of the above

    Correct Answer
    B. Non-static function of the class
    Explanation
    The reference being referred to in the question is a "built-in reference," which suggests that it is a reference to a built-in object or feature within the programming language. The answer states that this built-in reference can only be used within a non-static function of the class. This implies that the built-in reference has certain limitations or restrictions, and it can only be accessed or utilized within a specific type of function in the class.

    Rate this question:

  • 16. 

    Object communicate with each other by sending messages in the form of

    • A.

      Class

    • B.

      Through inheritance

    • C.

      Functions

    • D.

      None of the above

    Correct Answer
    C. Functions
    Explanation
    Objects communicate with each other by sending messages in the form of functions. Functions are a way for objects to interact with each other and perform specific actions. They can be called by one object and executed by another, allowing for communication and collaboration between different objects in a program. Through the use of functions, objects can pass data, trigger actions, and respond to events, enabling them to work together to achieve a desired outcome.

    Rate this question:

  • 17. 

    Data is given less importance in

    • A.

      Structure programming language

    • B.

      Object-oriented language

    • C.

      Procedural language

    • D.

      Object based language

    Correct Answer
    C. Procedural language
    Explanation
    A procedural language is a programming language that follows a linear, step-by-step approach to solving a problem. In procedural programming, data is given less importance compared to the sequence of instructions or procedures that manipulate the data. The focus is on writing procedures or functions that perform specific tasks. This approach is often used in languages like C, Pascal, and Fortran, where the emphasis is on breaking down a problem into smaller, manageable parts and executing them in a specific order. Therefore, data is not given as much significance as the sequence of instructions in a procedural language.

    Rate this question:

  • 18. 

    Which of the following is an example of procedural programming language?

    • A.

      C++

    • B.

      ALGOL

    • C.

      Java

    • D.

      Ruby

    Correct Answer
    B. ALGOL
    Explanation
    ALGOL is an example of a procedural programming language. Procedural programming focuses on writing step-by-step instructions or procedures to solve a problem. ALGOL, short for Algorithmic Language, was one of the earliest high-level programming languages developed in the late 1950s. It was designed to be used for scientific and engineering computations and featured a block structure, allowing for the creation of reusable code blocks. Although not widely used today, ALGOL played a significant role in the development of subsequent programming languages, influencing the design of languages like Pascal and C.

    Rate this question:

  • 19. 

    Which command disassembles a class file?

    • A.

      Javac

    • B.

      Javah

    • C.

      Javap

    • D.

      Jdb

    Correct Answer
    C. Javap
    Explanation
    The command "javap" is used to disassemble a class file in Java. It allows the user to view the bytecode instructions and other information about the class file. By running "javap" followed by the name of the class file, the user can see the structure, fields, and methods of the class in a human-readable format. This command is helpful for debugging and understanding the internal workings of a Java program.

    Rate this question:

  • 20. 

    Java supports Unicode character set which is

    • A.

      20 bits

    • B.

      64 bits

    • C.

      32 bits

    • D.

      16 bits

    Correct Answer
    D. 16 bits
    Explanation
    Java supports Unicode character set which uses 16 bits to represent each character. Unicode is a universal character encoding standard that supports a wide range of characters from different scripts and languages. In Java, characters are represented using the UTF-16 encoding scheme, where each character is stored in 16 bits. This allows Java to handle and manipulate characters from various languages and scripts effectively.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 17, 2015
    Quiz Created by
    Sanjayc

Related Topics

Back to Top Back to top
Advertisement