Considering JAVA, Give an example of a class and an example of an object. Describe what a class is, what an object is, and how they are related. Use your examples to illustrate the descriptions.
Your Discussion should be at least 250 words in length, but not more than 750 words.
Class is a group of elements having common properties and
behaviours.
And Object is an individual element among the group of elements
having physical behaviours and
physical properties
1.Class:
Syntax:
[Access_Modifiers] class Class_Name [extends
Super_Class_Name][implements
interface_List]
{
--- variables-----
-- methods--------
----constructors-----
----blocks------
---classes-------
----abstract classes-----
---interfaces------
---- enums--------
}
Where
Access Modifiers:
There are two types of Access modifiers
1.To define scopes to the progvramming elements, there are four types of access modifiers.
public, protected, <default> and private.
Where public and <default> are allowed for classes, protected and private are not allowed for
classes.
2.To define some extra nature to the programming elements , we have the following access
modifiers.
static, final, abstract, native, volatile, transient, synchronized, strictfp,.......
Where final, abstract and strictfp are allowed for the classes
To store entities data temporarily in java applications we need
objects.
To Access the members of any particular class we need
objects.
If we want to create Objects we have to use the following
syntax.
Class_Name ref_Var = new Class_Name([param_List]);
EX:
class A{
----
}
A a = new A();
When JVM encounter the above instruction,JVM will perform the
following actions.
1.Creating memory for the Object
2.Generating Identities for the object
3.Providing initializations inside the Object
Example of class and Object is given below:
import java.io.*;
class Check
{
String s;
Check(String s)
{
this.s=s;
}
void check()
{
String n=s.trim();
int length=n.length();
if((n.charAt(0)=='x'||n.charAt(0)=='X')&&n.charAt(length-1)=='x'||n.charAt(length-1)=='X')
{
System.out.println("Output:"+n.substring(1,length-1));
}
else if(n.charAt(0)=='x'||n.charAt(0)=='X')
{
System.out.println("Output:"+n.substring(1));
}
else if(n.charAt(length-1)=='x'||n.charAt(length-1)=='X')
{
System.out.println("Output:"+n.substring(0,length-1));
}
}
}
class Demo
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Input:");
String s=br.readLine();
Check ch=new Check(s);
ch.check();
}
}
Output:
in above program there are two
classes are defined and one object is defined to access tge data of
that class we can access method ,variab va, constructor from the
class using object.we can not write java program withaout class we
require atleast one class to write java program .
Considering JAVA, Give an example of a class and an example of an object. Describe what...
What are some of the reasons people delay or avoid medical care? Describe 2-3 barriers to visiting a health professional and explain how they affect help-seeking behavior. Discuss potential problems related to delaying or avoiding medical care as well as potential solutions for improving help-seeking behavior. End your discussion post with one well thought out question related to this unit from which your colleagues can formulate a response or generate further discussion. Your Discussion should be at least 250 words...
What is exception propagation? Give an example of a class that contains at least two methods, in which one method calls another. Ensure that the subordinate method will call a predefined Java method that can throw a checked exception. The subordinate method should not catch the exception. Explain how exception propagation will occur in your example.
JAVA you will design and write a class that represents a real-world object of your choice. In the second part, you will write a program that demonstrates the use of the class. Part I: Select a "real-world" object that has not been used in class lecture and/or the textbook. The object you choose must be defined by at least: Have at least two characteristics (attributes). Have at least two behaviors (operations). The class that you write to represent the object...
Describe how you would develop object-oriented features of Java for the Quiz program developed in the Programming Assignments. In particular, describe how the program could use each of the following: class variables, instance variables, inheritance, polymorphism, abstract classes, "this", "super", interfaces, and event listeners. Your Discussion should be at least 250 words in length, but not more than 750 words. QUIZ PROGRAM EXAMPLE: Files "QuestionDialog.java": import java.awt.event.*; import javax.swing.*; public class QuestionDialog extends JDialog implements ActionListener { String answer; public...
Explain the following object-oriented(OO) concepts with the aid of code examples (either C++ or Java): Inheritance Over-riding . Over-loading Describe any differences between C++ and Java in how these OO concepts are implemented? 3(c) 17 Marks] Describe C++ namespaces using a code example. Describe Java packages, again using a code example. How do C++ namespaces compare to Java packages? 3(d) [5 Marks] What are inline methods in C++/Java? Explain the terms accessor and mutator.
Explain the following object-oriented(OO) concepts with...
Java is an object-oriented programming language that enables us to define classes and to instantiate them into objects. These objects then call each other’s methods to implement the behavior of the application. The Unified Modeling Language (UML) is an object-oriented visual notation to document the design of object-oriented classes. For this discussion, you will practice designing a Java class called Course, drawing a UML class diagram for the Course class, and then implementing the Course class in Java code. Review...
1. Discuss the primary and secondary surveys, and give an example of each. 2. Discuss how you would conduct a Neuro exam, and give an example of how such exam should be administered. Respond to two other learners in the discussion thread. 3. Describe how you would help someone who is in respiratory distress, and give at least two examples on how you would respond to that individual.
Java Homework Question: Explain how class (static) variables and methods differ from their instance counterparts. Give an example of a class that contains at least one class variable and at least one class method. Don't forget to provide the code. Also, explain why using a class variable and method rather than an instance variable and method would be the correct choice in the example you select.
Describe three authentication types and give an example of each. Your post should be at least 350 words.
Java - Object Oriented Programming
Declare a class named Customer that has two private fields? Write a set method to make sure that if age > 125 years or less than 0 then it is set to 0 (default value) What does it indicate when declaring a class's instance variables with private access modifier? What is the role of a constructor? The data part of by an object's instance variables is known as? Do all methods have to always return...