QUESTIONS FOR AVERAGE BLOOMERS

Similar documents
The Java language has a wide variety of modifiers, including the following:

Inheritance. Benefits of Java s Inheritance. 1. Reusability of code 2. Code Sharing 3. Consistency in using an interface. Classes

OVERRIDING. 7/11/2015 Budditha Hettige 82

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

Programming II (CS300)

Object Oriented Programming. Java-Lecture 11 Polymorphism

Java Object Oriented Design. CSC207 Fall 2014

Inheritance. Transitivity

JAVA MOCK TEST JAVA MOCK TEST II

C++ Important Questions with Answers

IT101. Inheritance, Encapsulation, Polymorphism and Constructors

Inheritance and Polymorphism

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Chapter 5 Object-Oriented Programming

ITI Introduction to Computing II

CS 251 Intermediate Programming Inheritance

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

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

CS Programming I: Inheritance

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.

ITI Introduction to Computing II

CS260 Intro to Java & Android 03.Java Language Basics

Practice for Chapter 11

CSCE3193: Programming Paradigms

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University

CS-202 Introduction to Object Oriented Programming

Programming II (CS300)

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

Programming overview

Inheritance and object compatibility

Class, Variable, Constructor, Object, Method Questions

What is Inheritance?

Objective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5

Data Abstraction. Hwansoo Han

Example: Count of Points

Inheritance -- Introduction

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

More About Objects. Zheng-Liang Lu Java Programming 255 / 282

8. Polymorphism and Inheritance

Starting Out with Java: From Control Structures Through Objects Sixth Edition

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.

CMSC 132: Object-Oriented Programming II

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

Polymorphism and Inheritance

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

What are the characteristics of Object Oriented programming language?

Programming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017

C++ Inheritance and Encapsulation

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

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

INHERITANCE. Spring 2019

Unit 4 - Inheritance, Packages & Interfaces

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

INHERITANCE AND EXTENDING CLASSES

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

ENCAPSULATION. private, public, scope and visibility rules. packages and package level access.

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

ECE 122. Engineering Problem Solving with Java

The major elements of the object-oriented model

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

Inheritance & Polymorphism

1 Shyam sir JAVA Notes

Inheritance. Chapter 7. Chapter 7 1

CS111: PROGRAMMING LANGUAGE II

The software crisis. code reuse: The practice of writing program code once and using it in many contexts.

Software Development. Modular Design and Algorithm Analysis

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

Arrays Classes & Methods, Inheritance

First IS-A Relationship: Inheritance

Big software. code reuse: The practice of writing program code once and using it in many contexts.

PROGRAMMING LANGUAGE 2

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

More on Objects in JAVA TM

Darshan Institute of Engineering & Technology for Diploma Studies Unit 3

Inheritance, Polymorphism, and Interfaces

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Inheritance and Polymorphism. CS180 Fall 2007

Chapter 5. Inheritance

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

Polymorphism. Object Orientated Programming in Java. Benjamin Kenwright

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Java Magistère BFA

15CS45 : OBJECT ORIENTED CONCEPTS

Overriding Variables: Shadowing

Polymorphism 2/12/2018. Which statement is correct about overriding private methods in the super class?

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

More Relationships Between Classes

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Lecture Notes on Programming Languages

Chapter 14 Abstract Classes and Interfaces

(12-1) OOP: Polymorphism in C++ D & D Chapter 12. Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University

Inheritance, and Polymorphism.

Lecture 18 CSE11 Fall 2013 Inheritance

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

CLASSES AND OBJECTS IN JAVA

Chapter 6 Introduction to Defining Classes

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes

Transcription:

MANTHLY TEST JULY 2017 QUESTIONS FOR AVERAGE BLOOMERS 1. How many types of polymorphism? Ans- 1.Static Polymorphism (compile time polymorphism/ Method overloading) 2.Dynamic Polymorphism (run time polymorphism/ Method Overriding) 2. What do you mean by Abstraction? Ans - Abstraction in Object Oriented Programming refers to the ability to make a class abstract. 3. Which type of inheritance java support? Ans Multiple only 4. How one can make a test field un-editable on a frame? Ans- jtextfield1.seteditable(false) 5. How many types of containers can a java GUI application contain? Ans- A java GUI application can contain as many containers as it needs but with a condition that it must have atleast one top level container. 6. What is the use of Final Keyword in Java? Ans The final keyword in java is used to restrict the user. 7. What do you understand by packages? Ans - Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc.

8. Name any two packages. Ans- java.lang, java.io 9. What is method? Ans A method is a subprogram that acts on data and often returns a value. 10. What is the use of access specifier? Ans To set access levels for classes, variables, methods and constructors. Questions for Brilliant achiever 1. What is Static Polymorphism? Ans - The ability to execute different method implementations by altering the argument used with the method name is known as method overloading. 2. What is Dynamic Polymorphism /run time polymorphism/ Method Overriding? Ans - When you create a subclass by extending an existing class, the new subclass contains data and methods that were defined in the original superclass. In other words, any child class object has all the attributes of its parent. 3. Which keyword is used for inheritance in JAVA? Ans In java extends keyword is used for inheritance. 4. What is the use of final keyword,explain? Ans The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be:

1. variable 2. method 3. class The final keyword can be applied with the variables, a final variable that have no value it is called blank final variable or uninitialized final variable. It can be initialized in the constructor only. 5. Give an example of packages? Ans - /* File name : Animal.java */ package animals; interface Animal { public void eat(); public void travel(); 6. What is the use of access specifier? Explain. Ans - Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are: Visible to the package. the default. No modifiers are needed. Visible to the class only (private). Visible to the world (public). Visible to the package and all subclasses (protected). 7. What is default access specifier? Ans- Default access modifier means we do not explicitly declare an access modifier for a class, field, method, etc. A variable or method declared without any

access control modifier is available to any other class in the same package. The fields in an interface are implicitly public static final and the methods in an interface are by default public. 8. Can a variable which is declared private accessed outside? Explain with reason. Ans- Yes,Variables that are declared private can be accessed outside the class if public getter methods are present in the class. 9. Give an example of private access specifier? Ans- public class Logger { private String format; public String getformat() { return this.format; public void setformat(string format) { this.format = format; Here, the format variable of the Logger class is private, so there's no way for other classes to retrieve or set its value directly. 10. Explain protected access specifier? Ans The protected access modifier cannot be applied to class and interfaces. Methods, fields can be declared protected, however methods and fields in a interface cannot be declared protected. Protected access gives the subclass a chance to use the helper method or variable, while preventing a nonrelated class from trying to use it.

Example: The following parent class uses protected access control, to allow its child class override openspeaker() method: class AudioPlayer { protected boolean openspeaker(speaker sp) { // implementation details class StreamingAudioPlayer { boolean openspeaker(speaker sp) { // implementation details Here, if we define openspeaker() method as private, then it would not be accessible from any other class other than AudioPlayer. If we define it as public, then it would become accessible to all the outside world. But our intension is to expose this method to its subclass only, thats why we used protected modifier.

Question for late bloomers 1. What is encapsulation? Ans - It refers to binding the data and its associated methods together in a single unit. 2. What is Polymorphism? Ans polymorphism refers to do many task. 3. What is Inheritance? Ans- The process of deriving multiple functions from one class to another. 4. What is class? Ans A class is a template for objects. 5. What is object? Ans An object is an instance of a class. 6. What is sub class? Ans- The derived class is a subclass or a child class. 7. What is message? Ans A message is the information sent to the application. 8. What is super class? Ans The original class that is used to derive a new class is called a superclass. 9. What command do you need to write in actionperformed() event handler of a button, in order to make aexit button? Ans- System.exit(0); 10. How can you make a Text Field un-editable on a frame? Ans- jtextfield1.seteditable(false);