CLASSES AND OBJECTS IN JAVA

Similar documents
Programming II (CS300)

CS304 Object Oriented Programming Final Term

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Inheritance and Polymorphism

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

What are the characteristics of Object Oriented programming language?

And Even More and More C++ Fundamentals of Computer Science

Objects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes

Microsoft Visual Basic 2005: Reloaded

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Programming II (CS300)

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

STRUCTURING OF PROGRAM

Chapter 6 Introduction to Defining Classes

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?

Programming II (CS300)

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

EMBEDDED SYSTEMS PROGRAMMING OO Basics

Programming II (CS300)

CS313D: ADVANCED PROGRAMMING LANGUAGE

Chapter 7. Inheritance

Object Oriented Programming. Solved MCQs - Part 2

CS304 Object Oriented Programming

PROGRAMMING LANGUAGE 2

CMSC 132: Object-Oriented Programming II

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance

Inheritance, and Polymorphism.

Chapter 5 Object-Oriented Programming

Object Orientated Analysis and Design. Benjamin Kenwright

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

More C++ : Vectors, Classes, Inheritance, Templates

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

More C++ : Vectors, Classes, Inheritance, Templates. with content from cplusplus.com, codeguru.com

Java Primer 1: Types, Classes and Operators

JAVA MOCK TEST JAVA MOCK TEST II

OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Object-Oriented Programming

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)

CMSC 132: Object-Oriented Programming II

SEEM4570 System Design and Implementation. Lecture 11 From Design to Implementation

CS250 Final Review Questions

CS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC

Practice for Chapter 11

CSC1322 Object-Oriented Programming Concepts

Introduction to Programming Using Java (98-388)

Short Notes of CS201

G Programming Languages - Fall 2012

CS360 Lecture 5 Object-Oriented Concepts

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS201 - Introduction to Programming Glossary By

Lesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014

Starting Savitch Chapter 10. A class is a data type whose variables are objects. Some pre-defined classes in C++ include int,

OBJECT ORİENTATİON ENCAPSULATİON

Object Oriented Paradigm

What is Inheritance?

Object Oriented Programming in C#

C++ Important Questions with Answers

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

CGS 2405 Advanced Programming with C++ Course Justification

Data Structures (list, dictionary, tuples, sets, strings)

CPS 506 Comparative Programming Languages. Programming Language

Inheritance and Polymorphism

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Data Abstraction. Hwansoo Han

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

Objects and Classes. Basic OO Principles. Classes in Java. Mark Allen Weiss Copyright 2000

Class, Variable, Constructor, Object, Method Questions

Inheritance and Polymorphism

ENCAPSULATION AND POLYMORPHISM

C++ Inheritance and Encapsulation

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class

Object Oriented Programming with c++ Question Bank

Inheritance -- Introduction

Cpt S 122 Data Structures. Introduction to C++ Part II

Basics of Object Oriented Programming. Visit for more.

Java Object Oriented Design. CSC207 Fall 2014

An Introduction to C++

Object-Oriented Programming

Part 3. Why do we need both of them? The object-oriented programming paradigm (OOP) Two kinds of object. Important Special Kinds of Member Function

Chapter 4 Defining Classes I


CompuScholar, Inc. Alignment to Nevada "Computer Science" Course Standards

C++ (Non for C Programmer) (BT307) 40 Hours

Object-Oriented Programming (OOP) Fundamental Principles of OOP

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

EECS168 Exam 3 Review

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).

C++ (classes) Hwansoo Han

Chapter 12 Object-Oriented Programming. Starting Out with Games & Graphics in C++ Tony Gaddis

Lecture 18 Tao Wang 1

Today s lecture. CS 314 fall 01 C++ 1, page 1

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

Module 10 Inheritance, Virtual Functions, and Polymorphism

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects

15CS45 : OBJECT ORIENTED CONCEPTS

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Transcription:

Lesson 8 CLASSES AND OBJECTS IN JAVA (1) Which of the following defines attributes and methods? (a) Class (b) Object (c) Function (d) Variable (2) Which of the following keyword is used to declare Class variable and class methods? (a) static (b) private (c) public (d) package (3) Which of the following operator creates an object and returns its reference? (a) assign (b) static (c) new (d) create (4) Which of the following method can be called without creating an instance of a class? (a) Instance method (b) Class method (c) Constructor method (5) Which of the following refers more than one method having same name but different parameters? (a) Overloaded methods (b) Overridden methods (c) Duplicate methods (6) Which method is invoked automatically with common of an object? (a) Instance method (b) Constructor (c) Class method (d) All of the above (7) Which of the following is the keyword used to refer a super class constructor in subclass constructor? (a) extends (b) super (c) new (d) public (8) Which of the following is used to invoke an instance method in Java? (a) The name of the object, colon(;) and the name of the method. (b) The name of the object, dot(.) and the name of the method. (c) The name of the class, colon(;) and the name of the method. (d) The name of the class, dot(.) and the name of the method. (9) Which of the following is accessible by instance methods? (a) Only instance variables (b) Only class variables (c) Both Instance variables and class variables (10) When methods in the super class and sub class have same name and signature, what are they called? (a) Overloaded methods (b) Overridden methods (c) Inherited methods (11) A contains data and program code. (a) object (b) class (c) function (d) constructor (12) A can also be considered as a design for the real life objects. (a) object (b) class (c) function (d) constructor (13) The shares the common characteristics of a class. (a) object (b) property (c) function (d) variable (14) Every class in Java is generally made up of components. (a) two (b) three (c) four (d) five (15) are defined by variables in a class. (a) Attributes (b) Methods (c) Objects (16) are used to access or modify attributes of a class. (a) Attributes (b) Methods (c) Objects (17) A variable name of type class is declared with syntax <class name> <variable name> is termed as (18) Keyword new is used to create the object by allocating memory is termed as (19) Constructor is called to initialize the newly created object is termed as (20) The syntax of the class object declaration is : (a) <class name> <method><objectname>; (b)<classname><objectname>; (c) <method> <class name> <object name>; 12 EM Lesson-7 Classes and Object in Java (www.verymicro.org) Page 1

(21) Reference is the of the memory location where the object is stored. (a) pointer (b) address (c) operator (d) citation (22) The objects live in the special portion of the memory called the (a) mass (b) heap (c) stack (d) mound (23) When an object is created to allocating memory, a special method is executed. (a) creator (b) inventor (c) constructor (d) designer (24) Which of the following is correct object created as per Java? (a) String str=new String( I Love India ); (b) Room r=new Room( ) (c) Both (a) & (b) (25) In object-oriented programming (OOP) languages, creating an object is called (26) Class is an representation of an object. (a) abstract (b) intangible (c) elusive (d) obscure (27) All instances of class are allocated memory in data structure called (a) mass (b) heap (c) stack (d) mound (28) Instance variables and instance methods are accessed via (a) attributes (b) methods (c) operators (d) objects (29) The syntax for accessing methods or variables of a class is: (a) <class name>.<instance variable or method> (b) <object reference>.<instance variable or method> (c) <class reference>.<object reference> (30) When the variables are referred within the methods of the same class, there is not need to use dot(.) operator. (a) Instance (b) class (c) constructor (31) The new keyword returns a to an object that represents an instance of the class. (a) instance (b) reference (c) address (d) variable (32) Instance variables and instance methods are access via (a) classes (b) variables (c) abstract (d) objects (33) Instance variables and instance methods can be accessed using operator. (a) dot(.) (b) dollar($) (c) modulus (%) (d) comma (,) (34) Which of the following statement(s) is/ are incorrect? (a) Every object is created using new keyword. (b) Every object has its own instance variables occupying different spaces in memory. (c) Values of instance variables are stored in class itself. (d) The class variable should be allocated the memory only once per class. (35) The variables can be accessed without creating an instance of a class. (a) static (b) instance (c) global (d) local (36) Which of the following statement(s) is/ are incorrect? (a) Class variables and class methods can be accessed using a class name or reference variable. (b) Instance variables and instance methods can t be accessed from class methods. (c) Class methods do not belong to any object. (d) Instance variables do not belong to any object. (37) Variables defined inside methods or blocks are called variables. (a) static (b) instance (c) class (d) local (38) The variables are defined within a class but outside any method. (a) static (b) instance (c) global (d) local (39) The variables are defined within a class, outside any method, with the static keyword. (a) local (b) instance (c) global (d) class 12 EM Lesson-7 Classes and Object in Java (www.verymicro.org) Page 2

(40) Which of the following statement(s) is/ are incorrect? (a) Instance variables are allocated memory from heap area. (b) Instance variables are initialized by default values. (c) Class variables shares the memory with all its objects. (d) Instance variables are allocated memory only once per class & shared by all its objects. (41) The word polymorphism means (a) many things (b) single thing (c) many forms (d) single form (42) Java provides the different forms of methods with same name, which is termed as (a) Data Hiding (b) Data Abstraction (c) Encapsulation (d) Polymorphism (43) When a single method is having different signatures (syntaxes) it is termed as (a) method unloading (b) method overloading (c) method reloading (d) method loading (44) Java facilitates to create methods with same name but different parameters, this facility is termed as (a) method unloading (b) method overloading (c) method reloading (d) method loading (45) is a special kind of method that is invoked when a new object is created. (a) Local (b) Constructor (c) Destructor (d) Global (46) Which of the following statement(s) is/are correct in context of Constructors in Java? (a) Constructors must have the same name as of the object names. (b) Constructors do not have any return type. (c) Constructors are invoked explicitly anywhere in the program. (d) Constructors are local methods. (47) Which of the following statement(s) is/are correct in context of Constructors in Java? (a) Constructors must have the same name as class name. (b) Constructors return the class type. (c) Constructors cannot be overloaded. (d) Constructors are global methods. (48) Which of the following statement(s) is/are correct in context of Constructors in Java? (a) Constructors can be overloaded. (b) Constructors return the class type. (c) Constructors are invoked explicitly anywhere in the program. (d) Constructors are global methods. (49) If the name of class is Room in java, which of the following is the default constructor? (a) Room( ) (b) Room(float l, float w) (c) static void Room( ) (d) double Room(float l, float w) (50) If the name of class is Room in java, which of the following is the constructor with arguments? (a) Room( ) (b) Room(float l, float w) (c) static void Room( ) (d) double Room(float l, float w) (51) Match the table of Access Modifier with its visibility. Access Modifier Visibility 1) public : i) 2) package : ii) widest 3) protected : iii) narrowest 4) private : iv) (a) 1-ii, 2-iv, 3-i, 4-iii (b) 1-ii, 2-iv, 3-i, 4-iii (c) 1-iii, 2-iv, 3-ii, 4-i (d) 1-iv, 2-iii, 3-ii, 4-i (52) modifiers are also known as visibility modifiers. (a) Access (b) Control (c) Display (d) Program 12 EM Lesson-7 Classes and Object in Java (www.verymicro.org) Page 3

(53) modifiers are about controlling visibility in Java. (a) Access (b) Control (c) Display (d) Program (54) There are levels of visibility to provide necessary protection. (a) two (b) three (c) four (d) five (55) is used to organize classes. (a) Public (b) Protected (c) Private (d) Package (56) Which of the following statement is incorrect? (a) The Four P s of protection are public, package, protected and private. (b) public, protected and private are used before the type of variable or method. When a file does not have package statement, the class defined in the file are placed in default package. (d) protected visibility is the default mode. (57) If the user wants to make visible the methods or variables of class to outside that class, those variables and methods have to be visibility mode. (58) The variables and methods are visible anywhere and thus can be accessed from other source files and packages also. (59) The default of visibility protection is access modifier. (60) The source file without package statement is considered as a package by (a) loaded (b) default (c) overloaded (d) user defined (61) The level of protection of is used to allow the access only to subclasses or to share with the methods declared as friend. (62) Highest level of protection can be achieved by using the protection level. (63) The methods and variables are directly accessible only by the methods defined within a class. (64) The variables and methods of class cannot be seen in other class, when the visibility protection level is used as (65) The protection level provides data encapsulation, data hiding, limiting its manipulation. (66) The best way to provide data encapsulation is to make as much data as as possible. (67) To access the private variables from another class : (a) It can be directly accessed from other class. (b) It can be made available indirectly by the accessible methods. (c) It can be made available directly by the private methods. (d) It is not possible to access the private members from another class. (68) When the user restricts access to date by declaring them as private, the purpose is to proect them from getting directly accessed or modified by methods of other class. If user want to allow such data to be used by others, then the user should write methods. (a) restricted (b) mutator (c) accessor (d) processor (69) If the user wants to allow the restricted data to be modified by others, then user should write the methods. (a) restricted (b) mutator (c) accessor (d) processor 12 EM Lesson-7 Classes and Object in Java (www.verymicro.org) Page 4

(70) The accessor methods are also termed as (71) The mutator methods are also termed as (72) If the user wants to allow other methods to read only the data value, the user should use methods. (73) If the user wants to allow other methods to modify the data value, the user should use methods. (74) The use of method(s) will prevent the variables from getting directly accessed and modified by other class. (a) accessor (b) mutator (c) Both (a) & (b) (75) models is-a relationship between two classes. (a) Aggregation (b) Composition (c) Inheritance 12 EM Lesson-7 Classes and Object in Java (www.verymicro.org) Page 5