面向对象练习

python面向对象练习题01 练习题一 # 1.定义一个Person类,它包含数据成员age, name和gender。 # a.从Person中派生一个类Employee,在新类中添加一个数据成员,存储个人的number. # b、再从Employee中派生一个类Executive,每个派生类都应该定义一个方法, # 来显示相关的信息(名称和类型,如”Fred Smith is an Employee”)。 # c.编写一个列表,包含3个Executive对象,2个一般的Employee对象,然后显示它们的信息。 代码展示: . 阅读详情

package Zuoye;
public class Demo {

     String name;
     int age;  //私有属性,只能在当前类中调用
     int weight;

public Demo(){

}

public Demo(String name,int age,int weight){

this.name = name;

this.age = age;

this.weight = weight;

}

    public void eat(){
        System.out.println("吃奥利给");
    }

    public void play(){
        System.out.println("玩奥利给");
    }

    public void show(){
        System.out.println("name:" +this.name);
        System.out.println("age:" +this.age);
        System.out.println("weight:" +this.weight);
    }
 

public static void main(String[] args){

Deno demo = new Demo();

demo.name = "精神顺";

demo.age = 18;

demo.weight = 130;

demo.show();

}

}

Java面向对象程序设计——练习2 练习-Java继承和多态之方法重写 练习-Java继承和多态之接口 练习-Java继承和多态之综合练习 练习-Java异常处理之try-catch之异常捕获 练习-Java继承和多态之abstract类 阅读详情

相关推荐

JavaScript重点: 面向对象编程知识点全面总结和练习

JavaScript面向对象编程知识点全面总结和练习

2402_84051608的博客 1730

Java面向对象练习

下面给你几个练习题,覆盖封装、继承、多态、抽象和接口等知识点。

wincl0的博客 757

【软件使用】Calibre部分提参的实战技巧与常见问题解析

本文深入解析Calibre部分提参(Partial Extraction)的实战技巧与常见问题,涵盖PEX、hcell和xcell文件的高级应用。通过实际案例展示如何提升电路仿真效率,解决时钟信号失真等复杂问题,并提供版图设计中的防坑指南,助力芯片设计工程师优化工作流程。

weixin_28717431的博客 162

C++面向对象练习

马上要期末了,复习的同时写一篇博客也巩固一下基础知识,这些练习虽然简单,但是一不小心还是会出错,比如在练习1中重载输出流是将<<写成>>,练习4中忘记预先分配数组内存,在练习7中忘记给类加public,所以就算是再简单的项目,再简单的题也要注意好细节,不然调试半天才发现竟然是自己的粗心导致的;另外,你如果感兴趣的话可以关注我,看看我其他的博客对你有没有帮助,我后续也会持续产出更高质量的博客。最后,希望这篇博客能帮助到你。

2401_88685396的博客 928

别再手动改文献了!手把手教你定制Mendeley的GB/T 7714-2005引用格式(附常见问题修复)

本文详细指导如何定制Mendeley的GB/T 7714-2005引用格式,解决科研文献管理中的常见问题。通过深度解析Mendeley样式编辑器,精准控制作者显示规则、出版社信息精简及期刊页码处理,实现参考文献一键合规。附常见问题修复和实战调试方法,大幅提升学术写作效率。

weixin_26833503的博客 374

学习笔记( 11 ) - 解决:finalshell连接虚拟机(ubuntu)超时,主机ping不通虚拟机,主机没有VMnet8网卡, Connection refused: connect

解决:finalshell连接虚拟机(ubuntu)超时,主机ping不通虚拟机,主机没有VMnet8网卡, Connection refused: connect

烟溪彭于晏的博客 2万+

python面向对象练习02

练习题一 # 5、某公司雇员(Employee)包括经理(Manager),技术人员(Technician)和销售员(Salesman)。 # 以Employee类为基类派生出Manager,Technician和Salesman类; # Employee类的属性包括姓名、职工号、工资级别,月薪(实发基本工资加业绩工资)。 # 操作包括月薪计算方法(pay()),该方法要求输入请假天数,扣去应扣工资后,得出实发基本工资。 # Technician类派生的属性有每小时附加酬金和当月工作时数,及研究完成进度

qq_44850339的博客 815

C#中使用OpenCV的常用函数

c# opencv 常见操作

大黄鸭在发光的专栏 1079

Java面向对象基础小练习。

    最后回顾一遍面向对象基础部分,后面就开始慢慢进阶了。    所有题目均来自:https://www.jianshu.com/p/886252693889    在练习中,有意识的规范代码格式,发现新东西,这才是练习的目的。    原帖中源代码就不贴上来了,贴上的的均为本人所编写,类、变量命名参考原帖。    【练习题】01.类的成员变量 猜数字游戏一个类A有一个成员变量v有一个初值100。...

yaerpi的博客 2169

解锁RK3588芯片超强网络性能:多队列网卡与IRQ负载均衡实战

摘要:本文针对RK3588芯片的网络性能优化展开研究,重点探讨了多队列网卡配置和IRQ负载均衡技术。通过配置多队列网卡,将网络流量分散到多个队列处理,显著提升了吞吐量(测试显示提升67%)。同时,通过IRQ负载均衡配置使中断请求均匀分配到各CPU核心,CPU利用率降低至35%。文章详细介绍了配置步骤、测试方法,并分析了常见问题及解决方案。这些优化措施有效提升了RK3588在网络录像机、边缘计算等应用场景中的性能表现,为高性能网络应用提供了有力支持。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 498

【Python爬虫(1)】专栏开篇:夯实Python基础

要想熟练掌握 Python 爬虫技术,扎实的 Python 基础是必不可少的。这就好比建造高楼大厦,Python 基础就是那稳固的基石。只有打好了这个基础,我们才能在爬虫的学习道路上稳步前行,理解并运用各种爬虫技术和框架。

邓邓子的博客 2026

Python面向对象练习题

Python面向对象练习题 【下载地址】Python面向对象练习题 这份Python面向对象练习题资料专为编程学习者设计,尤其适合希望通过实践加深理解的教育工作者和学生。内容涵盖类与对象的定义、继承、多态等核心概念,每道练习题均附有详细解答和解析,助你轻松掌握知识点。通过独立完成练习并对照答案,你将有效提升Python面...

gitblog_06707的博客 434

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

面向对象练习题【从零开始学Java】

从零开始学Java系列课程

波波烤鸭的博客 1167

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Java入门程序之面向对象基础练习

(1)声明一个圆的图形类,包含实例变量/属性:半径(2)在测试类的main中,创建2个圆类的对象,并给两个圆对象的半径属性赋值,最后显示两个圆的半径值、周长和面积值​ 提示:圆周率可以使用Math.PI。

m0_73334365的博客 1651

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

学会面向对象经典练习题21道

19.主方法中给定数组int[] arr= {20,10,40,30,50,60};如:给定数字3 求出3在数组 int[] arr = {3,4,3,5,7,9};20.定义一个方法,求出给定的数字在给定int型数组中出现的次数,如果一次没有出现则返回0。数组{1,2,3,2} 要查找的数是5 则方法每部会打印 “数组中没有这个数字”如: 数组{1,2,3,2} 要查找的数是2 则方法内部会打印索引值 1 3。要求:枚举值:MON,TUE,WED,THR,FRI,SAT,SUN。

qq_46189388的博客 2303

Scala总结之基础练习和面向对象

Scala总结二之基础练习和面向对象一. scala基础练习1.1. 字符串转换为数字1.2. 使用scala完成选择排序1.3. 使用scala完成二分查找二. scala面向对象2.1. 类的基本操作2.1.1. 类的创建与对象的构造2.1.2. 成员变量的封装getter和setter2.1.3. case class模拟javabean2.1.4. scala类的构造器2.1.5. 嵌套类...

Baiyabai的博客 815

C# —— 面向对象编程练习

C# —— 面向对象编程练习 基础题 代码如下: class Program { static void Main(string[] args) { rectangle r = new rectangle(); Console.WriteLine("调用不含参构造函数初始化后矩形的长为{0},宽为{1}", r.GetLength().ToString(), r.GetWidth().ToString());

Deam_swan_goose的博客 5693

面向对象练习2

CV在读 169

PHP面向对象练习题的深度探讨

假如情况是这样的话,通过练习题,我们可以将所学的理论知识与实际编程实践相结合,更好地理解和掌握OOP的核心概念,如类、对象、继承、封装和多态等。如果按照这个逻辑来看的话,通过不断的练习,我们可以提高自己的编程能力,为未来的职业发展打下坚实的基础。在这个背景下,要想真正掌握PHP的OOP特性,仅仅停留在理论学习是远远不够的,我们还需要通过大量的练习来巩固和应用。通过选择合适的练习题并付出持续的努力和时间进行实践和总结,我们可以更好地理解和掌握OOP的核心概念和技术细节,为未来的编程之路打下坚实的基础。

2401_86114608的博客 313

java中关于面向对象数组的练习

​ 通过这个简单的面向对象数组练习,能够很好的锻炼到我们的逻辑思维能力,在实现每一个功能时都要进行思考如何进行,最终通过不同的方法实现对对象数组的具体操作。虽然整个问题的要求较多,但拆分成不同的步骤来实现就能很清晰的实现。

2501_91651005的博客 463

Java构造方法与面向对象练习

Java构造方法与面向对象练习 一、构造方法概述 1、构造方法概述和作用 是为了创建对象,给对象中的成员进行初始化。 2、构造方法格式特点 (1)方法名和类名一样 (2)没有返回值类型,连void都没有 (3)没有具体的返回值 3、构造方法的注意事项 (1)一般情况下我们没有给出,系统会默认提供一个空参构造。 (2)若是我们给出了有参构造,系统将不会再提供无参构造,若还是需要无参构造,则需要你自己手动给出。 二、面向对象标准学生类 public class Stude

ZJMing_sir的博客 282

Day17:一些数组练习题、简单面向对象练习

import java.util.Arrays; import java.util.Scanner; public class Demo05 { //3. 写一个函数,计算一个整数数组的平均值 // public static void main(String[] args) { // int[] arr = { 1, 2, 3, 4, 5 }; // getAvg(arr); // }...

Biubiubiu! 454

面向对象代码练习

代码练习一: 1,设计出英雄这种类 类名:Hreo 英雄有如下属性: 名字 name,类型是字符串String 血量 hp,类型是浮点型float 护甲 armor,类型是浮点型float 移动速度 moveSpeed,类型是整型 int 创建(实例化)2个英雄 /** *面向对象实例(一) */ //定义‘英雄’类 public class Hero { //定义‘...

grace♥的博客 687
上一篇: 面向对象——Package
下一篇: 面向对象——get,set方法
Java_gml
博客等级 码龄5年 324粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值