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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


tabish ahmad
oops
1 Answer(s)      3 years and 9 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
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
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
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
Advertisements
 

 

 

DMCA.com