Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


tabish ahmad
oops
1 Answer(s)      3 years and 5 months ago
Posted in : Java Interview Questions


can we access protected data members of base class in derived class directly


Advertisement
View Answers

February 19, 2011 at 3:07 PM


Access Protected Members

Yes, you can.

Here is an example:

class Protected{
    protected int num=5;
    protected void protectedMethod() {
        System.out.println("Hello");
    }
}
class AccessProtectedMembers extends Protected{
    public static void main(String[]args){
        AccessProtectedMembers a = new AccessProtectedMembers();
       System.out.println(a.num);
       a.protectedMethod();
    }
}


Related Tutorials/Questions & Answers:
OOPs
OOPs  What is OOps?  Object oriented programming organizes a program around its data,i.e.,objects and a set of well defined interfaces to that data.An object-oriented program can be characterized as data controlling
oops concepts
oops concepts  What is polymorphism?Explain with an example. What is abstraction?Explain with an example. What is inheritance?Explain with an example. What is encapsulation?Explain with an example
Advertisements
what is oops in java
what is oops in java  what is oops in java
what is oops in java
what is oops in java  what is oops in java
Java & OOPs
Java & OOPs  Is JAVA a fully Object Oriented Language? or A what degree Java supports Fully OOPs concept?   Java is not a fully object oriented language because Java is not a completely object oriented language
What is oops in php with example?
What is oops in php with example?  Hi, I heard some where that PHP is support OOPS and its new feature is PHP. Every is now using OOPs in PHP. What is oops in php with example? Can anyone give me code example? Thanks
What is OOPs in PHP ?
What is OOPs in PHP ?   Hi, I am a beginner in PHP Programming Application. I have some doubt on What is OOPs in PHP programming. How the OOPs concept helps us in PHP Programming. Please provide me any online reference so that i
Oops Definition - Java Beginners
Oops Definition  What is Abstraction and Encapsulation? What is the Difference Between Abstraction and Encapsulation? Regards M.KethraBalan.  Hi Friend, Abstraction - The process of abstraction in Java is used
What Is OOPS In Java
What Is OOPS In Java In this section we will learn about the basics of Java. Here we will see the concepts of OOPs. We will discuss the basics of OOPs. OOPs, stands for Object Oriented Programming System that specifies a model
oops concepts - Java Interview Questions
oops concepts  what stands for "S" in OOPs ? object oriented programing.....  Hi friend, Object Oriented Programming or OOP is the technique to create programs based on the real world. Unlike procedural programming
using oops concepts - Development process
using oops concepts  i want answer with oops concepts.individual classes with source code and exact out put. You are required to develop a Hotel Reservation System. The system manages information about rooms
using oops concepts - Development process
using oops concepts   You are required to develop a Hotel Reservation System. The system manages information about rooms, reservations, customers... total source code in corejava using oops concepts.  Hi
OOPs Concept
OOPs Concept      ... the OOPs concepts along with  fundamentals  used to develop the java.... This is a technique used to create programs around the real world entities. In OOPs
OOPs concepts in Java
Object-Oriented Programming (OOPs) concepts in Java helps in creating programs that are based on real world. OOPs is very flexible and compatible and hence... application that are developed on the OOPs concepts at first analyze the program
OOPS Concept Abstraction with example - Java Beginners
OOPS Concept Abstraction with example  I am new to java. In java OOPS concept Abstraction means abstract or something. Please explain it with one example  Hi Friend, The process of abstraction in Java is used
Program to read 2 integers using oops concepts
Program to read 2 integers using oops concepts  Write a program to read two integers with the following significance. ? The first integer value represents a time of day on a 24 hour clock, so that 1245 represents quarter
how to insert data from database using oops concepts - Development process
how to insert data from database using oops concepts  Hi, How to insert data from database using oops based concepts.please write the code and send me.using class and constructor..its urgent  Hi Friend, Try
Inheritance in Java 7
This tutorial describe concept of Inheritance. It is one of OOPs concept
Polymorphism in Java 7
This tutorial describe concept of Polymorphism. It is one of OOPs concept
Java7 : OOPs Concepts
JAVA7 : OOPs Concept In this section we will discuss concept of Object..., better termed as OOPs is a paradigm where everything is represented as an object.... Everything in OOPs is written inside the class so that you can reuse the class.You
OOPs and Its Concepts in Java
OOPs and Its Concepts in Java       Brief Introduction to OOP Object Oriented Programming or OOP is the technique to create programs based on the real world
OOP
OOP       OOPs stands... and scenerios. OOPs enables to program the real world objects and easily play with them in our application development scenerios. OOPs focuses on the relevant data
Object-Oriented Language: Java / APIs, Java OOPs
Java OOPs In this section we will learn Object Oriented (OOPs) Concepts  of Java. This will give you brief introduction to the oops features of Java. Java is one of the useful Object Oriented programming language. Other Object
Encapsulation in Java 7
Encapsulation in Java 7 This tutorial describe concept of  Encapsulation. It is one of OOPs concept. Encapsulation : Encapsulation is a way of wrapping up data and methods into a single unit. Encapsulation puts the data safe from
Abstraction in Java 7
Abstraction in Java 7 This section elaborate about abstraction. It is one of OOPs concept. Abstraction :  Abstraction means hiding the unnecessary information to the user and show only essential features of a particular concept
Polymorphism
Polymorphism        OOPs revolve around the four concepts: 1. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts are implemented through
Encapsulation
Encapsulation       OOPs revolve around the four concepts: 1. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts are implemented through a class
Inheritance
Inheritance        OOPs revolve around the four concepts: 1. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts are implemented through a class
What is Polymorphism in Java?
Polymorphism in Java means a subclass, though having its own unique behavior, can also share some functionality of its parent class. It is a part of (Object Oriented Programing) OOPs concept that allows object of various types to define
Java as an Object Oriented Language
will discuss the OOPs concepts along with their role in developing the java... entities. In OOPs programming model, programs are developed around data rather than actions and logics. In OOPs, every real life object has properties and behavior
Object Oriented Programming in Java
OOPS acronym for Object Oriented Programming is a model or concept that works... concept are used to create programs based on the real world. By the name OOPS..., and identity, which can be clubbed together. The principal aim of OOPS is to find
Using Super class Variables With Sub-classed Objects
Using Super class Variables With Sub-classed Objects          One of the strong features of java is that it is follows a OOPs concept, and one of the feature
Abstraction in Java
Abstraction in Java Abstraction is one of the four pillar of OOPS Concept. Abstraction in java is a process by which hiding the irrelevant data  and exposing only the essential feature of object. In java Abstraction
Inheritance in Java
Inheritance, one of the important concepts of Object Oriented Programming (OOPS) defines a general class and establishes a subtype from an existing object. Benefit of using inheritance: A code can be used again and again
Difference between C++ and Java
Java and C++ are Object Oriented Programming (OOPs) language. Java is derived from C++ , hence both has many similarities. C++ is considered more complex when compared to Java . C++ was designed for infrastructure
Features of Java
Java is a class based Object Oriented Programming (OOPs) language, which...: Java is an Object Oriented Programming (OOPs) language and provides simple... supports following four characteristics of OOPs: Inheritance: Process
Encapsulation in Java
Encapsulation along with Inheritance, Polymorphism, and Abstraction are the four concepts of Object Oriented Programming (OOPs). Encapsulation in Java is the technique of binding or wrapping the data and the codes in a class private
Difference between Java and C++
Difference between Java and C++ Java is an Object Oriented Programming(OOPs) language, developed by James Gosling 1992. Important feature of java is that it allows the developer to Write Once Run Anywhere (WORA) meaning
OOP - Java Beginners
OOP Design Pattern  What is the oops design patterns
java
java  which one is purely based on oops 1)java 2)c++   Hi Friend, Java is purely oops based language. Thanks
update query
update query  using oops concept in php.. How to update the data from databse ? with program example
question
question  which language is leading the world java or .net and which language followed by all the Oops principles either java or .net
Advertisements
 

 

 

DMCA.com